aboutsummaryrefslogtreecommitdiffstats
path: root/eth
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 /eth
parent7f85608f30a2e34005c8d15566849229c758c2f1 (diff)
downloaddexon-78cff9e3a4c71d003c5ab3f5747ccae1dbc959fe.tar.gz
dexon-78cff9e3a4c71d003c5ab3f5747ccae1dbc959fe.tar.zst
dexon-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 'eth')
-rw-r--r--eth/backend.go31
1 files changed, 17 insertions, 14 deletions
diff --git a/eth/backend.go b/eth/backend.go
index 141c6c605..c253a064e 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -42,11 +42,11 @@ type Config struct {
ProtocolVersion int
NetworkId int
- DataDir string
- LogFile string
- LogLevel int
- LogFormat string
- VmDebug bool
+ DataDir string
+ LogFile string
+ LogLevel int
+ LogJSON string
+ VmDebug bool
MaxPeers int
Port string
@@ -136,7 +136,7 @@ type Ethereum struct {
blockSub event.Subscription
miner *miner.Miner
- logger logger.LogSystem
+ // logger logger.LogSystem
Mining bool
DataDir string
@@ -147,7 +147,10 @@ type Ethereum struct {
func New(config *Config) (*Ethereum, error) {
// Boostrap database
- servlogsystem := logger.New(config.DataDir, config.LogFile, config.LogLevel, config.LogFormat)
+ logger.New(config.DataDir, config.LogFile, config.LogLevel)
+ if len(config.LogJSON) > 0 {
+ logger.NewJSONsystem(config.DataDir, config.LogJSON)
+ }
newdb := config.NewDB
if newdb == nil {
@@ -174,12 +177,12 @@ func New(config *Config) (*Ethereum, error) {
servlogger.Infof("Protocol Version: %v, Network Id: %v", config.ProtocolVersion, config.NetworkId)
eth := &Ethereum{
- shutdownChan: make(chan bool),
- blockDb: blockDb,
- stateDb: stateDb,
- extraDb: extraDb,
- eventMux: &event.TypeMux{},
- logger: servlogsystem,
+ shutdownChan: make(chan bool),
+ blockDb: blockDb,
+ stateDb: stateDb,
+ extraDb: extraDb,
+ eventMux: &event.TypeMux{},
+ // logger: servlogsystem,
accountManager: config.AccountManager,
DataDir: config.DataDir,
version: config.Name, // TODO should separate from Name
@@ -303,7 +306,7 @@ func (s *Ethereum) StartMining() error {
func (s *Ethereum) StopMining() { s.miner.Stop() }
func (s *Ethereum) IsMining() bool { return s.miner.Mining() }
-func (s *Ethereum) Logger() logger.LogSystem { return s.logger }
+// func (s *Ethereum) Logger() logger.LogSystem { return s.logger }
func (s *Ethereum) Name() string { return s.net.Name }
func (s *Ethereum) AccountManager() *accounts.Manager { return s.accountManager }
func (s *Ethereum) ChainManager() *core.ChainManager { return s.chainManager }