diff options
author | Taylor Gerring <taylor.gerring@gmail.com> | 2015-03-24 01:27:06 +0800 |
---|---|---|
committer | Taylor Gerring <taylor.gerring@gmail.com> | 2015-03-24 01:27:06 +0800 |
commit | 90c710fd2687a0c9f3b3e4f5f3b9b69febc506e8 (patch) | |
tree | effeee4521ab0bb0dccc00ae5c3df15e6a3c55f5 | |
parent | e954c24af02802cdee0870230b6dcfc898dd07cd (diff) | |
parent | a983a215dc50240615cc1efe5199c72cefe037ed (diff) | |
download | dexon-90c710fd2687a0c9f3b3e4f5f3b9b69febc506e8.tar.gz dexon-90c710fd2687a0c9f3b3e4f5f3b9b69febc506e8.tar.zst dexon-90c710fd2687a0c9f3b3e4f5f3b9b69febc506e8.zip |
Merge pull request #552 from ethersphere/jsonlog
Jsonlog
-rw-r--r-- | cmd/ethtest/main.go | 9 | ||||
-rw-r--r-- | logger/logsystem.go | 12 | ||||
-rw-r--r-- | p2p/testlog_test.go | 7 | ||||
-rw-r--r-- | tests/helper/init.go | 2 |
4 files changed, 13 insertions, 17 deletions
diff --git a/cmd/ethtest/main.go b/cmd/ethtest/main.go index f5b423e8d..952ba1bd6 100644 --- a/cmd/ethtest/main.go +++ b/cmd/ethtest/main.go @@ -33,12 +33,12 @@ import ( "strings" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/logger" - "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/tests/helper" - "github.com/ethereum/go-ethereum/core/vm" ) type Log struct { @@ -80,8 +80,7 @@ func StateObjectFromAccount(db common.Database, addr string, account Account) *s } type VmTest struct { - Callcreates interface{} - //Env map[string]string + Callcreates interface{} Env Env Exec map[string]string Transaction map[string]string @@ -219,7 +218,7 @@ func RunVmTest(r io.Reader) (failed int) { } func main() { - //helper.Logger.SetLogLevel(5) + helper.Logger.SetLogLevel(5) vm.Debug = true if len(os.Args) > 1 { diff --git a/logger/logsystem.go b/logger/logsystem.go index 995cf4240..4dadb126e 100644 --- a/logger/logsystem.go +++ b/logger/logsystem.go @@ -14,17 +14,17 @@ type LogSystem interface { // NewStdLogSystem creates a LogSystem that prints to the given writer. // The flag values are defined package log. -func NewStdLogSystem(writer io.Writer, flags int, level LogLevel) LogSystem { +func NewStdLogSystem(writer io.Writer, flags int, level LogLevel) *StdLogSystem { logger := log.New(writer, "", flags) - return &stdLogSystem{logger, uint32(level)} + return &StdLogSystem{logger, uint32(level)} } -type stdLogSystem struct { +type StdLogSystem struct { logger *log.Logger level uint32 } -func (t *stdLogSystem) LogPrint(msg LogMsg) { +func (t *StdLogSystem) LogPrint(msg LogMsg) { stdmsg, ok := msg.(stdMsg) if ok { if t.GetLogLevel() >= stdmsg.Level() { @@ -33,11 +33,11 @@ func (t *stdLogSystem) LogPrint(msg LogMsg) { } } -func (t *stdLogSystem) SetLogLevel(i LogLevel) { +func (t *StdLogSystem) SetLogLevel(i LogLevel) { atomic.StoreUint32(&t.level, uint32(i)) } -func (t *stdLogSystem) GetLogLevel() LogLevel { +func (t *StdLogSystem) GetLogLevel() LogLevel { return LogLevel(atomic.LoadUint32(&t.level)) } diff --git a/p2p/testlog_test.go b/p2p/testlog_test.go index c524c154c..ac973bcf5 100644 --- a/p2p/testlog_test.go +++ b/p2p/testlog_test.go @@ -15,11 +15,8 @@ func testlog(t *testing.T) testLogger { return l } -func (testLogger) GetLogLevel() logger.LogLevel { return logger.DebugDetailLevel } -func (testLogger) SetLogLevel(logger.LogLevel) {} - -func (l testLogger) LogPrint(level logger.LogLevel, msg string) { - l.t.Logf("%s", msg) +func (l testLogger) LogPrint(msg logger.LogMsg) { + l.t.Logf("%s", msg.String()) } func (testLogger) detach() { diff --git a/tests/helper/init.go b/tests/helper/init.go index e0892d8f6..73d563e02 100644 --- a/tests/helper/init.go +++ b/tests/helper/init.go @@ -7,7 +7,7 @@ import ( logpkg "github.com/ethereum/go-ethereum/logger" ) -var Logger logpkg.LogSystem +var Logger *logpkg.StdLogSystem var Log = logpkg.NewLogger("TEST") func init() { |