diff options
author | Taylor Gerring <taylor.gerring@gmail.com> | 2015-01-22 00:17:07 +0800 |
---|---|---|
committer | Taylor Gerring <taylor.gerring@gmail.com> | 2015-01-22 00:17:07 +0800 |
commit | bdf99e098126880c10dc2ef68623c47ec6f04537 (patch) | |
tree | c7264b48d8012701911753565c0a11aea069bbb2 | |
parent | acdc19d1b7b25d6ebd8457f423659f3d112a4a75 (diff) | |
download | dexon-bdf99e098126880c10dc2ef68623c47ec6f04537.tar.gz dexon-bdf99e098126880c10dc2ef68623c47ec6f04537.tar.zst dexon-bdf99e098126880c10dc2ef68623c47ec6f04537.zip |
Add LogFormat flag
-rw-r--r-- | cmd/ethereum/flags.go | 2 | ||||
-rw-r--r-- | cmd/ethereum/main.go | 1 | ||||
-rw-r--r-- | eth/backend.go | 3 | ||||
-rw-r--r-- | logger/log.go | 10 |
4 files changed, 13 insertions, 3 deletions
diff --git a/cmd/ethereum/flags.go b/cmd/ethereum/flags.go index f829744dc..885cdfe5b 100644 --- a/cmd/ethereum/flags.go +++ b/cmd/ethereum/flags.go @@ -57,6 +57,7 @@ var ( ConfigFile string DebugFile string LogLevel int + LogFormat string Dump bool DumpHash string DumpNumber int @@ -110,6 +111,7 @@ func Init() { flag.StringVar(&ConfigFile, "conf", defaultConfigFile, "config file") flag.StringVar(&DebugFile, "debug", "", "debug file (no debugging if not set)") flag.IntVar(&LogLevel, "loglevel", int(logger.InfoLevel), "loglevel: 0-5: silent,error,warn,info,debug,debug detail)") + flag.StringVar(&LogFormat, "logformat", "std", "logformat: std,raw)") flag.BoolVar(&DiffTool, "difftool", false, "creates output for diff'ing. Sets LogLevel=0") flag.StringVar(&DiffType, "diff", "all", "sets the level of diff output [vm, all]. Has no effect if difftool=false") flag.BoolVar(&ShowGenesis, "genesis", false, "Dump the genesis block") diff --git a/cmd/ethereum/main.go b/cmd/ethereum/main.go index b816c678e..b7997d485 100644 --- a/cmd/ethereum/main.go +++ b/cmd/ethereum/main.go @@ -67,6 +67,7 @@ func main() { DataDir: Datadir, LogFile: LogFile, LogLevel: LogLevel, + LogFormat: LogFormat, Identifier: Identifier, MaxPeers: MaxPeer, Port: OutboundPort, diff --git a/eth/backend.go b/eth/backend.go index c3c7d1287..da75da051 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -29,6 +29,7 @@ type Config struct { DataDir string LogFile string LogLevel int + LogFormat string KeyRing string MaxPeers int @@ -80,7 +81,7 @@ type Ethereum struct { func New(config *Config) (*Ethereum, error) { // Boostrap database - logger := ethlogger.New(config.DataDir, config.LogFile, config.LogLevel) + logger := ethlogger.New(config.DataDir, config.LogFile, config.LogLevel, config.LogFormat) db, err := ethdb.NewLDBDatabase("blockchain") if err != nil { return nil, err diff --git a/logger/log.go b/logger/log.go index 53065f870..baa3dfaf2 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) LogSystem { +func New(datadir string, logFile string, logLevel int, logFormat string) LogSystem { var writer io.Writer if logFile == "" { writer = os.Stdout @@ -26,7 +26,13 @@ func New(datadir string, logFile string, logLevel int) LogSystem { writer = openLogFile(datadir, logFile) } - sys := NewStdLogSystem(writer, log.LstdFlags, LogLevel(logLevel)) + var sys LogSystem + switch logFormat { + case "raw": + sys = NewRawLogSystem(writer, 0, LogLevel(logLevel)) + default: + sys = NewStdLogSystem(writer, log.LstdFlags, LogLevel(logLevel)) + } AddLogSystem(sys) return sys |