aboutsummaryrefslogtreecommitdiffstats
path: root/ethlog/loggers_test.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-08-01 16:22:25 +0800
committerobscuren <geffobscura@gmail.com>2014-08-01 16:22:25 +0800
commit8bed47a2d4377b7a49f34350ae5c5ea50464b95d (patch)
tree3b1923c6560da3a08bfb88783e49b353f2609ea9 /ethlog/loggers_test.go
parent5a2d62e4d9e551f16f094216da70b7a6f5d2bf00 (diff)
parent9831619881c5264c2449ce1b906108d892b6e1e1 (diff)
downloaddexon-8bed47a2d4377b7a49f34350ae5c5ea50464b95d.tar.gz
dexon-8bed47a2d4377b7a49f34350ae5c5ea50464b95d.tar.zst
dexon-8bed47a2d4377b7a49f34350ae5c5ea50464b95d.zip
Merge branch 'feature/ethutil-refactor' of https://github.com/ethersphere/eth-go into ethersphere-feature/ethutil-refactor
Diffstat (limited to 'ethlog/loggers_test.go')
-rw-r--r--ethlog/loggers_test.go30
1 files changed, 21 insertions, 9 deletions
diff --git a/ethlog/loggers_test.go b/ethlog/loggers_test.go
index 89f416681..a9b1463e7 100644
--- a/ethlog/loggers_test.go
+++ b/ethlog/loggers_test.go
@@ -28,8 +28,19 @@ func (t *TestLogSystem) GetLogLevel() LogLevel {
return t.level
}
-func quote(s string) string {
- return fmt.Sprintf("'%s'", s)
+func TestLoggerFlush(t *testing.T) {
+ logger := NewLogger("TEST")
+ testLogSystem := &TestLogSystem{level: WarnLevel}
+ AddLogSystem(testLogSystem)
+ for i := 0; i < 5; i++ {
+ logger.Errorf(".")
+ }
+ Flush()
+ Reset()
+ output := testLogSystem.Output
+ if output != "[TEST] .[TEST] .[TEST] .[TEST] .[TEST] ." {
+ t.Error("Expected complete logger output '[TEST] .[TEST] .[TEST] .[TEST] .[TEST] .', got ", output)
+ }
}
func TestLoggerPrintln(t *testing.T) {
@@ -41,10 +52,11 @@ func TestLoggerPrintln(t *testing.T) {
logger.Infoln("info")
logger.Debugln("debug")
Flush()
+ Reset()
output := testLogSystem.Output
fmt.Println(quote(output))
if output != "[TEST] error\n[TEST] warn\n" {
- t.Error("Expected logger output '[TEST] error\\n[TEST] warn\\n', got ", quote(testLogSystem.Output))
+ t.Error("Expected logger output '[TEST] error\\n[TEST] warn\\n', got ", output)
}
}
@@ -57,10 +69,10 @@ func TestLoggerPrintf(t *testing.T) {
logger.Infof("info")
logger.Debugf("debug")
Flush()
+ Reset()
output := testLogSystem.Output
- fmt.Println(quote(output))
if output != "[TEST] error to { 2}\n[TEST] warn" {
- t.Error("Expected logger output '[TEST] error to { 2}\\n[TEST] warn', got ", quote(testLogSystem.Output))
+ t.Error("Expected logger output '[TEST] error to { 2}\\n[TEST] warn', got ", output)
}
}
@@ -73,13 +85,14 @@ func TestMultipleLogSystems(t *testing.T) {
logger.Errorln("error")
logger.Warnln("warn")
Flush()
+ Reset()
output0 := testLogSystem0.Output
output1 := testLogSystem1.Output
if output0 != "[TEST] error\n" {
- t.Error("Expected logger 0 output '[TEST] error\\n', got ", quote(testLogSystem0.Output))
+ t.Error("Expected logger 0 output '[TEST] error\\n', got ", output0)
}
if output1 != "[TEST] error\n[TEST] warn\n" {
- t.Error("Expected logger 1 output '[TEST] error\\n[TEST] warn\\n', got ", quote(testLogSystem1.Output))
+ t.Error("Expected logger 1 output '[TEST] error\\n[TEST] warn\\n', got ", output1)
}
}
@@ -94,9 +107,8 @@ func TestFileLogSystem(t *testing.T) {
Flush()
contents, _ := ioutil.ReadFile(filename)
output := string(contents)
- fmt.Println(quote(output))
if output != "[TEST] error to test.log\n[TEST] warn\n" {
- t.Error("Expected contents of file 'test.log': '[TEST] error to test.log\\n[TEST] warn\\n', got ", quote(output))
+ t.Error("Expected contents of file 'test.log': '[TEST] error to test.log\\n[TEST] warn\\n', got ", output)
} else {
os.Remove(filename)
}