Documentation ¶
Overview ¶
Package logger implements a multi-output leveled logger.
Other packages use tagged logger to send log messages to shared (process-wide) logging engine. The shared logging engine dispatches to multiple log systems. The log level can be set separately per log system.
Logging is asynchronous and does not block the caller. Message formatting is performed by the caller goroutine to avoid incorrect logging of mutable state.
Index ¶
- func AddLogSystem(sys LogSystem)
- func Flush()
- func Reset()
- type EthChainNewHead
- type EthChainReceivedNewBlock
- type EthMinerNewBlock
- type EthTxReceived
- type JsonLog
- type JsonLogger
- type LogEvent
- type LogLevel
- type LogStarting
- type LogSystem
- type Logger
- func (logger *Logger) DebugDetailf(format string, v ...interface{})
- func (logger *Logger) DebugDetailln(v ...interface{})
- func (logger *Logger) Debugf(format string, v ...interface{})
- func (logger *Logger) Debugln(v ...interface{})
- func (logger *Logger) Errorf(format string, v ...interface{})
- func (logger *Logger) Errorln(v ...interface{})
- func (logger *Logger) Fatalf(format string, v ...interface{})
- func (logger *Logger) Fatalln(v ...interface{})
- func (logger *Logger) Infof(format string, v ...interface{})
- func (logger *Logger) Infoln(v ...interface{})
- func (logger *Logger) Warnf(format string, v ...interface{})
- func (logger *Logger) Warnln(v ...interface{})
- type P2PConnected
- type P2PDisconnected
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddLogSystem ¶
func AddLogSystem(sys LogSystem)
AddLogSystem starts printing messages to the given LogSystem.
Types ¶
type EthChainNewHead ¶ added in v0.8.4
type EthChainNewHead struct { BlockHash string `json:"block_hash"` BlockNumber int `json:"block_number"` ChainHeadHash string `json:"chain_head_hash"` BlockPrevHash string `json:"block_prev_hash"` LogEvent }
func (*EthChainNewHead) EventName ¶ added in v0.8.4
func (l *EthChainNewHead) EventName() string
type EthChainReceivedNewBlock ¶ added in v0.8.4
type EthChainReceivedNewBlock struct { BlockHash string `json:"block_hash"` BlockNumber int `json:"block_number"` ChainHeadHash string `json:"chain_head_hash"` BlockPrevHash string `json:"block_prev_hash"` RemoteId int `json:"remote_id"` LogEvent }
func (*EthChainReceivedNewBlock) EventName ¶ added in v0.8.4
func (l *EthChainReceivedNewBlock) EventName() string
type EthMinerNewBlock ¶ added in v0.8.4
type EthMinerNewBlock struct { BlockHash string `json:"block_hash"` BlockNumber int `json:"block_number"` ChainHeadHash string `json:"chain_head_hash"` BlockPrevHash string `json:"block_prev_hash"` LogEvent }
func (*EthMinerNewBlock) EventName ¶ added in v0.8.4
func (l *EthMinerNewBlock) EventName() string
type EthTxReceived ¶ added in v0.8.4
type EthTxReceived struct { TxHash string `json:"tx_hash"` RemoteId string `json:"remote_id"` LogEvent }
func (*EthTxReceived) EventName ¶ added in v0.8.4
func (l *EthTxReceived) EventName() string
type JsonLogger ¶ added in v0.8.4
type JsonLogger struct {
Coinbase string
}
func NewJsonLogger ¶ added in v0.8.4
func NewJsonLogger() *JsonLogger
func (*JsonLogger) LogJson ¶ added in v0.8.4
func (logger *JsonLogger) LogJson(v JsonLog)
type LogEvent ¶ added in v0.8.4
type LogEvent struct {
// Guid string `json:"guid"`
Ts utctime8601 `json:"ts"`
}
type LogStarting ¶ added in v0.8.4
type LogStarting struct { ClientString string `json:"client_impl"` ProtocolVersion int `json:"eth_version"` LogEvent }
func (*LogStarting) EventName ¶ added in v0.8.4
func (l *LogStarting) EventName() string
type LogSystem ¶
type LogSystem interface { GetLogLevel() LogLevel SetLogLevel(i LogLevel) LogPrint(LogLevel, string) }
LogSystem is implemented by log output devices. All methods can be called concurrently from multiple goroutines.
Example ¶
filename := "test.log" file, _ := os.OpenFile(filename, os.O_RDWR|os.O_CREATE, os.ModePerm) fileLog := NewStdLogSystem(file, 0, WarnLevel) AddLogSystem(fileLog) stdoutLog := NewStdLogSystem(os.Stdout, 0, WarnLevel) AddLogSystem(stdoutLog) NewLogger("TAG").Warnln("reactor meltdown") // writes to both logs
Output:
func NewRawLogSystem ¶ added in v0.8.4
NewRawLogSystem creates a LogSystem that prints to the given writer without adding extra information. Suitable for preformatted output
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
A Logger prints messages prefixed by a given tag. It provides named Printf and Println style methods for all loglevels. Each ethereum component should have its own logger with a unique prefix.
Example ¶
logger := NewLogger("TAG") logger.Infoln("so awesome") // prints [TAG] so awesome logger.Infof("this %q is raw", "coin") // prints [TAG] this "coin" is raw
Output:
func (*Logger) DebugDetailf ¶
DebugDetailf writes a message with DebugDetailLevel.
func (*Logger) DebugDetailln ¶
func (logger *Logger) DebugDetailln(v ...interface{})
DebugDetailln writes a message with DebugDetailLevel.
func (*Logger) Debugln ¶
func (logger *Logger) Debugln(v ...interface{})
Debugln writes a message with DebugLevel.
func (*Logger) Errorln ¶
func (logger *Logger) Errorln(v ...interface{})
Errorln writes a message with ErrorLevel.
func (*Logger) Fatalln ¶
func (logger *Logger) Fatalln(v ...interface{})
Fatalln writes a message with ErrorLevel and exits the program.
func (*Logger) Infoln ¶
func (logger *Logger) Infoln(v ...interface{})
Infoln writes a message with InfoLevel.
type P2PConnected ¶ added in v0.8.4
type P2PConnected struct { RemoteId string `json:"remote_id"` RemoteAddress string `json:"remote_addr"` RemoteVersionString string `json:"remote_version_string"` NumConnections int `json:"num_connections"` LogEvent }
func (*P2PConnected) EventName ¶ added in v0.8.4
func (l *P2PConnected) EventName() string
type P2PDisconnected ¶ added in v0.8.4
type P2PDisconnected struct { NumConnections int `json:"num_connections"` RemoteId string `json:"remote_id"` LogEvent }
func (*P2PDisconnected) EventName ¶ added in v0.8.4
func (l *P2PDisconnected) EventName() string