aboutsummaryrefslogtreecommitdiffstats
path: root/logger/log.go
diff options
context:
space:
mode:
authorzelig <viktor.tron@gmail.com>2015-03-21 17:20:47 +0800
committerzelig <viktor.tron@gmail.com>2015-03-22 10:16:54 +0800
commit78cff9e3a4c71d003c5ab3f5747ccae1dbc959fe (patch)
tree0bdc1bb55b9bd73730f9de658e1d87273482761a /logger/log.go
parent7f85608f30a2e34005c8d15566849229c758c2f1 (diff)
downloadgo-tangerine-78cff9e3a4c71d003c5ab3f5747ccae1dbc959fe.tar.gz
go-tangerine-78cff9e3a4c71d003c5ab3f5747ccae1dbc959fe.tar.zst
go-tangerine-78cff9e3a4c71d003c5ab3f5747ccae1dbc959fe.zip
independent flag for json structured logging
- logjson flag remove logformat flag - passed to eth Config - logsystem not a field of Ethereum - LogSystem does not need to expose GetLogLevel/SetLogLevel - message struct just implements more generic LogMsg interface - LogMsg is a fmt.Stringer with Level() - jsonMsg ([]byte) implements LogMsg - remove "raw" systems - move level logic inside StdLogSystem - logsystems only print their kind of msg: jsonLogSystem prints jsonMsg, StdLogSystem prints stdMsg
Diffstat (limited to 'logger/log.go')
-rw-r--r--logger/log.go24
1 files changed, 16 insertions, 8 deletions
diff --git a/logger/log.go b/logger/log.go
index fab004d0a..e2a35ba53 100644
--- a/logger/log.go
+++ b/logger/log.go
@@ -18,7 +18,7 @@ func openLogFile(datadir string, filename string) *os.File {
return file
}
-func New(datadir string, logFile string, logLevel int, logFormat string) LogSystem {
+func New(datadir string, logFile string, logLevel int) LogSystem {
var writer io.Writer
if logFile == "" {
writer = os.Stdout
@@ -27,14 +27,22 @@ func New(datadir string, logFile string, logLevel int, logFormat string) LogSyst
}
var sys LogSystem
- switch logFormat {
- case "raw":
- sys = NewRawLogSystem(writer, 0, LogLevel(logLevel))
- case "json":
- sys = NewJsonLogSystem(writer, 0, LogLevel(logLevel))
- default:
- sys = NewStdLogSystem(writer, log.LstdFlags, LogLevel(logLevel))
+ sys = NewStdLogSystem(writer, log.LstdFlags, LogLevel(logLevel))
+ AddLogSystem(sys)
+
+ return sys
+}
+
+func NewJSONsystem(datadir string, logFile string) LogSystem {
+ var writer io.Writer
+ if logFile == "-" {
+ writer = os.Stdout
+ } else {
+ writer = openLogFile(datadir, logFile)
}
+
+ var sys LogSystem
+ sys = NewJsonLogSystem(writer)
AddLogSystem(sys)
return sys