Merge pull request #552 from ethersphere/jsonlog

Jsonlog
This commit is contained in:
Taylor Gerring 2015-03-23 18:27:06 +01:00
commit 90c710fd26
4 changed files with 13 additions and 17 deletions

View File

@ -33,12 +33,12 @@ import (
"strings" "strings"
"github.com/ethereum/go-ethereum/common" "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/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/logger" "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/tests/helper"
"github.com/ethereum/go-ethereum/core/vm"
) )
type Log struct { type Log struct {
@ -80,8 +80,7 @@ func StateObjectFromAccount(db common.Database, addr string, account Account) *s
} }
type VmTest struct { type VmTest struct {
Callcreates interface{} Callcreates interface{}
//Env map[string]string
Env Env Env Env
Exec map[string]string Exec map[string]string
Transaction map[string]string Transaction map[string]string
@ -219,7 +218,7 @@ func RunVmTest(r io.Reader) (failed int) {
} }
func main() { func main() {
//helper.Logger.SetLogLevel(5) helper.Logger.SetLogLevel(5)
vm.Debug = true vm.Debug = true
if len(os.Args) > 1 { if len(os.Args) > 1 {

View File

@ -14,17 +14,17 @@ type LogSystem interface {
// NewStdLogSystem creates a LogSystem that prints to the given writer. // NewStdLogSystem creates a LogSystem that prints to the given writer.
// The flag values are defined package log. // 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) logger := log.New(writer, "", flags)
return &stdLogSystem{logger, uint32(level)} return &StdLogSystem{logger, uint32(level)}
} }
type stdLogSystem struct { type StdLogSystem struct {
logger *log.Logger logger *log.Logger
level uint32 level uint32
} }
func (t *stdLogSystem) LogPrint(msg LogMsg) { func (t *StdLogSystem) LogPrint(msg LogMsg) {
stdmsg, ok := msg.(stdMsg) stdmsg, ok := msg.(stdMsg)
if ok { if ok {
if t.GetLogLevel() >= stdmsg.Level() { 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)) atomic.StoreUint32(&t.level, uint32(i))
} }
func (t *stdLogSystem) GetLogLevel() LogLevel { func (t *StdLogSystem) GetLogLevel() LogLevel {
return LogLevel(atomic.LoadUint32(&t.level)) return LogLevel(atomic.LoadUint32(&t.level))
} }

View File

@ -15,11 +15,8 @@ func testlog(t *testing.T) testLogger {
return l return l
} }
func (testLogger) GetLogLevel() logger.LogLevel { return logger.DebugDetailLevel } func (l testLogger) LogPrint(msg logger.LogMsg) {
func (testLogger) SetLogLevel(logger.LogLevel) {} l.t.Logf("%s", msg.String())
func (l testLogger) LogPrint(level logger.LogLevel, msg string) {
l.t.Logf("%s", msg)
} }
func (testLogger) detach() { func (testLogger) detach() {

View File

@ -7,7 +7,7 @@ import (
logpkg "github.com/ethereum/go-ethereum/logger" logpkg "github.com/ethereum/go-ethereum/logger"
) )
var Logger logpkg.LogSystem var Logger *logpkg.StdLogSystem
var Log = logpkg.NewLogger("TEST") var Log = logpkg.NewLogger("TEST")
func init() { func init() {