aboutsummaryrefslogtreecommitdiffstats
path: root/ethlog/loggers_test.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2014-10-16 16:50:51 +0800
committerFelix Lange <fjl@twurst.com>2014-10-17 23:23:29 +0800
commitc090a77f1c9bc890e67a00fb47a1c23c8769799d (patch)
treea01be1b9baf2b6cb4a0f133b40ab7219f395cdcd /ethlog/loggers_test.go
parent50f5ba5b0cfdf02cd87a9070676bd3c21c217296 (diff)
downloadgo-tangerine-c090a77f1c9bc890e67a00fb47a1c23c8769799d.tar
go-tangerine-c090a77f1c9bc890e67a00fb47a1c23c8769799d.tar.gz
go-tangerine-c090a77f1c9bc890e67a00fb47a1c23c8769799d.tar.bz2
go-tangerine-c090a77f1c9bc890e67a00fb47a1c23c8769799d.tar.lz
go-tangerine-c090a77f1c9bc890e67a00fb47a1c23c8769799d.tar.xz
go-tangerine-c090a77f1c9bc890e67a00fb47a1c23c8769799d.tar.zst
go-tangerine-c090a77f1c9bc890e67a00fb47a1c23c8769799d.zip
ethlog: simplify LogSystem interface
Messages are formatted by generic part, so the log system doesn't need to provide formatting. This fixes the test from the previous commit. As a small bonus, log systems now have access to the level of the message. This could be used to provide colored logging in the future.
Diffstat (limited to 'ethlog/loggers_test.go')
-rw-r--r--ethlog/loggers_test.go20
1 files changed, 4 insertions, 16 deletions
diff --git a/ethlog/loggers_test.go b/ethlog/loggers_test.go
index 23f649312..cf92e3cc6 100644
--- a/ethlog/loggers_test.go
+++ b/ethlog/loggers_test.go
@@ -1,7 +1,6 @@
package ethlog
import (
- "fmt"
"io/ioutil"
"math/rand"
"os"
@@ -16,15 +15,9 @@ type TestLogSystem struct {
level LogLevel
}
-func (ls *TestLogSystem) Println(v ...interface{}) {
+func (ls *TestLogSystem) LogPrint(level LogLevel, msg string) {
ls.mutex.Lock()
- ls.output += fmt.Sprintln(v...)
- ls.mutex.Unlock()
-}
-
-func (ls *TestLogSystem) Printf(format string, v ...interface{}) {
- ls.mutex.Lock()
- ls.output += fmt.Sprintf(format, v...)
+ ls.output += msg
ls.mutex.Unlock()
}
@@ -54,14 +47,9 @@ type blockedLogSystem struct {
unblock chan struct{}
}
-func (ls blockedLogSystem) Println(v ...interface{}) {
- <-ls.unblock
- ls.LogSystem.Println(v...)
-}
-
-func (ls blockedLogSystem) Printf(fmt string, v ...interface{}) {
+func (ls blockedLogSystem) LogPrint(level LogLevel, msg string) {
<-ls.unblock
- ls.LogSystem.Printf(fmt, v...)
+ ls.LogSystem.LogPrint(level, msg)
}
func TestLoggerFlush(t *testing.T) {