-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added docs, tests, fix existing tests
- Loading branch information
1 parent
f298a86
commit 0f5faf9
Showing
9 changed files
with
69 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Logs in Flank | ||
|
||
1. Log level depends on the output style. | ||
1. ```Simple, multi``` and ```verbose``` output style prints logs from ```SIMPLE``` and ```DETAILED``` levels. | ||
1. ```Compact``` style prints log only from ```SIMPLE``` level. | ||
1. If you want a print message for all output styles uses ```log``` or ```logLn``` with only ```message``` parameter. | ||
1. If you want print message more detailed message use ```log``` or ```logLn``` and set ```level``` to ```OutputLogLevel.DETAILED``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package ftl.log | ||
|
||
import com.google.common.truth.Truth | ||
import ftl.test.util.TestHelper.normalizeLineEnding | ||
import org.junit.After | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.contrib.java.lang.system.SystemOutRule | ||
|
||
class OutputLoggerTest { | ||
|
||
@Rule | ||
@JvmField | ||
val systemOutRule: SystemOutRule = SystemOutRule().enableLog().muteForSuccessfulTests() | ||
|
||
private val simpleMessage = "print for simple" | ||
private val detailedMessage = "print for detailed" | ||
|
||
@After | ||
fun afterTest() { | ||
setLogLevel(OutputLogLevel.DETAILED) | ||
} | ||
|
||
@Test | ||
fun `should print messages from all output levels if log level set to detailed`() { | ||
setLogLevel(OutputLogLevel.DETAILED) | ||
|
||
logLn(simpleMessage) | ||
logLn(detailedMessage, OutputLogLevel.DETAILED) | ||
|
||
Truth.assertThat(systemOutRule.log.normalizeLineEnding()).contains(simpleMessage) | ||
Truth.assertThat(systemOutRule.log.normalizeLineEnding()).contains(detailedMessage) | ||
} | ||
|
||
@Test | ||
fun `should print messages only simple output level if log level not set`() { | ||
setLogLevel(OutputLogLevel.SIMPLE) | ||
|
||
logLn(simpleMessage) | ||
logLn(detailedMessage, OutputLogLevel.DETAILED) | ||
|
||
Truth.assertThat(systemOutRule.log.normalizeLineEnding()).contains(simpleMessage) | ||
Truth.assertThat(systemOutRule.log.normalizeLineEnding()).doesNotContain(detailedMessage) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters