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 EthNewBlockBroadcasted
- type EthNewBlockChainIsCanonical
- type EthNewBlockChainIsOlder
- type EthNewBlockChainNotCanonical
- type EthNewBlockChainSwitched
- type EthNewBlockIsInvalid
- type EthNewBlockIsKnown
- type EthNewBlockIsNew
- type EthNewBlockMined
- type EthNewBlockMissingParent
- type EthNewBlockReceived
- type EthTxBroadcasted
- type EthTxCreated
- type EthTxIsInvalid
- type EthTxReceived
- type EthTxValidated
- 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 P2PConnecting
- type P2PDisconnected
- type P2PDisconnecting
- type P2PDisconnectingBadHandshake
- type P2PDisconnectingBadProtocol
- type P2PDisconnectingDHT
- type P2PDisconnectingReputation
- type P2PEthDisconnectingBadBlock
- type P2PEthDisconnectingBadTx
- type P2PHandshaked
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 EthNewBlockBroadcasted ¶
type EthNewBlockBroadcasted struct { BlockNumber int `json:"block_number"` HeadHash string `json:"head_hash"` BlockHash string `json:"block_hash"` BlockDifficulty int `json:"block_difficulty"` BlockPrevHash string `json:"block_prev_hash"` LogEvent }
func (*EthNewBlockBroadcasted) EventName ¶
func (l *EthNewBlockBroadcasted) EventName() string
type EthNewBlockChainIsCanonical ¶
type EthNewBlockChainIsCanonical struct { BlockNumber int `json:"block_number"` HeadHash string `json:"head_hash"` BlockHash string `json:"block_hash"` BlockDifficulty int `json:"block_difficulty"` BlockPrevHash string `json:"block_prev_hash"` LogEvent }
func (*EthNewBlockChainIsCanonical) EventName ¶
func (l *EthNewBlockChainIsCanonical) EventName() string
type EthNewBlockChainIsOlder ¶
type EthNewBlockChainIsOlder struct { BlockNumber int `json:"block_number"` HeadHash string `json:"head_hash"` BlockHash string `json:"block_hash"` BlockDifficulty int `json:"block_difficulty"` BlockPrevHash string `json:"block_prev_hash"` LogEvent }
func (*EthNewBlockChainIsOlder) EventName ¶
func (l *EthNewBlockChainIsOlder) EventName() string
type EthNewBlockChainNotCanonical ¶
type EthNewBlockChainNotCanonical struct { BlockNumber int `json:"block_number"` HeadHash string `json:"head_hash"` BlockHash string `json:"block_hash"` BlockDifficulty int `json:"block_difficulty"` BlockPrevHash string `json:"block_prev_hash"` LogEvent }
func (*EthNewBlockChainNotCanonical) EventName ¶
func (l *EthNewBlockChainNotCanonical) EventName() string
type EthNewBlockChainSwitched ¶
type EthNewBlockChainSwitched struct { BlockNumber int `json:"block_number"` HeadHash string `json:"head_hash"` OldHeadHash string `json:"old_head_hash"` BlockHash string `json:"block_hash"` BlockDifficulty int `json:"block_difficulty"` BlockPrevHash string `json:"block_prev_hash"` LogEvent }
func (*EthNewBlockChainSwitched) EventName ¶
func (l *EthNewBlockChainSwitched) EventName() string
type EthNewBlockIsInvalid ¶
type EthNewBlockIsInvalid struct { BlockNumber int `json:"block_number"` HeadHash string `json:"head_hash"` BlockHash string `json:"block_hash"` BlockDifficulty int `json:"block_difficulty"` BlockPrevHash string `json:"block_prev_hash"` LogEvent }
func (*EthNewBlockIsInvalid) EventName ¶
func (l *EthNewBlockIsInvalid) EventName() string
type EthNewBlockIsKnown ¶
type EthNewBlockIsKnown struct { BlockNumber int `json:"block_number"` HeadHash string `json:"head_hash"` BlockHash string `json:"block_hash"` BlockDifficulty int `json:"block_difficulty"` BlockPrevHash string `json:"block_prev_hash"` LogEvent }
func (*EthNewBlockIsKnown) EventName ¶
func (l *EthNewBlockIsKnown) EventName() string
type EthNewBlockIsNew ¶
type EthNewBlockIsNew struct { BlockNumber int `json:"block_number"` HeadHash string `json:"head_hash"` BlockHash string `json:"block_hash"` BlockDifficulty int `json:"block_difficulty"` BlockPrevHash string `json:"block_prev_hash"` LogEvent }
func (*EthNewBlockIsNew) EventName ¶
func (l *EthNewBlockIsNew) EventName() string
type EthNewBlockMined ¶
type EthNewBlockMined struct { BlockNumber int `json:"block_number"` HeadHash string `json:"head_hash"` BlockHash string `json:"block_hash"` BlockHexRlp string `json:"block_hexrlp"` BlockDifficulty int `json:"block_difficulty"` BlockPrevHash string `json:"block_prev_hash"` LogEvent }
func (*EthNewBlockMined) EventName ¶
func (l *EthNewBlockMined) EventName() string
type EthNewBlockMissingParent ¶
type EthNewBlockMissingParent struct { BlockNumber int `json:"block_number"` HeadHash string `json:"head_hash"` BlockHash string `json:"block_hash"` BlockDifficulty int `json:"block_difficulty"` BlockPrevHash string `json:"block_prev_hash"` LogEvent }
func (*EthNewBlockMissingParent) EventName ¶
func (l *EthNewBlockMissingParent) EventName() string
type EthNewBlockReceived ¶
type EthNewBlockReceived struct { BlockNumber int `json:"block_number"` HeadHash string `json:"head_hash"` BlockHash string `json:"block_hash"` BlockDifficulty int `json:"block_difficulty"` BlockPrevHash string `json:"block_prev_hash"` LogEvent }
func (*EthNewBlockReceived) EventName ¶
func (l *EthNewBlockReceived) EventName() string
type EthTxBroadcasted ¶
type EthTxBroadcasted struct { TxHash string `json:"tx_hash"` TxSender string `json:"tx_sender"` TxAddress string `json:"tx_address"` TxNonce int `json:"tx_nonce"` LogEvent }
func (*EthTxBroadcasted) EventName ¶
func (l *EthTxBroadcasted) EventName() string
type EthTxCreated ¶
type EthTxCreated struct { TxHash string `json:"tx_hash"` TxSender string `json:"tx_sender"` TxAddress string `json:"tx_address"` TxHexRLP string `json:"tx_hexrlp"` TxNonce int `json:"tx_nonce"` LogEvent }
func (*EthTxCreated) EventName ¶
func (l *EthTxCreated) EventName() string
type EthTxIsInvalid ¶
type EthTxIsInvalid struct { TxHash string `json:"tx_hash"` TxSender string `json:"tx_sender"` TxAddress string `json:"tx_address"` Reason string `json:"reason"` TxNonce int `json:"tx_nonce"` LogEvent }
func (*EthTxIsInvalid) EventName ¶
func (l *EthTxIsInvalid) EventName() string
type EthTxReceived ¶
type EthTxReceived struct { TxHash string `json:"tx_hash"` TxAddress string `json:"tx_address"` TxHexRLP string `json:"tx_hexrlp"` RemoteId string `json:"remote_id"` TxNonce int `json:"tx_nonce"` LogEvent }
func (*EthTxReceived) EventName ¶
func (l *EthTxReceived) EventName() string
type EthTxValidated ¶
type EthTxValidated struct { TxHash string `json:"tx_hash"` TxSender string `json:"tx_sender"` TxAddress string `json:"tx_address"` TxNonce int `json:"tx_nonce"` LogEvent }
func (*EthTxValidated) EventName ¶
func (l *EthTxValidated) EventName() string
type JsonLogger ¶
type JsonLogger struct {
Coinbase string
}
func NewJsonLogger ¶
func NewJsonLogger() *JsonLogger
func (*JsonLogger) LogJson ¶
func (logger *JsonLogger) LogJson(v JsonLog)
type LogStarting ¶
type LogStarting struct { ClientString string `json:"version_string"` Coinbase string `json:"coinbase"` ProtocolVersion int `json:"eth_version"` LogEvent }
func (*LogStarting) EventName ¶
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 ¶
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 ¶
type P2PConnected struct { NumConnections int `json:"num_connections"` RemoteId string `json:"remote_id"` LogEvent }
func (*P2PConnected) EventName ¶
func (l *P2PConnected) EventName() string
type P2PConnecting ¶
type P2PConnecting struct { RemoteId string `json:"remote_id"` RemoteEndpoint string `json:"remote_endpoint"` NumConnections int `json:"num_connections"` LogEvent }
func (*P2PConnecting) EventName ¶
func (l *P2PConnecting) EventName() string
type P2PDisconnected ¶
type P2PDisconnected struct { NumConnections int `json:"num_connections"` RemoteId string `json:"remote_id"` LogEvent }
func (*P2PDisconnected) EventName ¶
func (l *P2PDisconnected) EventName() string
type P2PDisconnecting ¶
type P2PDisconnecting struct { Reason string `json:"reason"` RemoteId string `json:"remote_id"` NumConnections int `json:"num_connections"` LogEvent }
func (*P2PDisconnecting) EventName ¶
func (l *P2PDisconnecting) EventName() string
type P2PDisconnectingBadHandshake ¶
type P2PDisconnectingBadHandshake struct { Reason string `json:"reason"` RemoteId string `json:"remote_id"` NumConnections int `json:"num_connections"` LogEvent }
func (*P2PDisconnectingBadHandshake) EventName ¶
func (l *P2PDisconnectingBadHandshake) EventName() string
type P2PDisconnectingBadProtocol ¶
type P2PDisconnectingBadProtocol struct { Reason string `json:"reason"` RemoteId string `json:"remote_id"` NumConnections int `json:"num_connections"` LogEvent }
func (*P2PDisconnectingBadProtocol) EventName ¶
func (l *P2PDisconnectingBadProtocol) EventName() string
type P2PDisconnectingDHT ¶
type P2PDisconnectingDHT struct { Reason string `json:"reason"` RemoteId string `json:"remote_id"` NumConnections int `json:"num_connections"` LogEvent }
func (*P2PDisconnectingDHT) EventName ¶
func (l *P2PDisconnectingDHT) EventName() string
type P2PDisconnectingReputation ¶
type P2PDisconnectingReputation struct { Reason string `json:"reason"` RemoteId string `json:"remote_id"` NumConnections int `json:"num_connections"` LogEvent }
func (*P2PDisconnectingReputation) EventName ¶
func (l *P2PDisconnectingReputation) EventName() string
type P2PEthDisconnectingBadBlock ¶
type P2PEthDisconnectingBadBlock struct { Reason string `json:"reason"` RemoteId string `json:"remote_id"` NumConnections int `json:"num_connections"` LogEvent }
func (*P2PEthDisconnectingBadBlock) EventName ¶
func (l *P2PEthDisconnectingBadBlock) EventName() string
type P2PEthDisconnectingBadTx ¶
type P2PEthDisconnectingBadTx struct { Reason string `json:"reason"` RemoteId string `json:"remote_id"` NumConnections int `json:"num_connections"` LogEvent }
func (*P2PEthDisconnectingBadTx) EventName ¶
func (l *P2PEthDisconnectingBadTx) EventName() string
type P2PHandshaked ¶
type P2PHandshaked struct { RemoteCapabilities []string `json:"remote_capabilities"` RemoteId string `json:"remote_id"` NumConnections int `json:"num_connections"` LogEvent }
func (*P2PHandshaked) EventName ¶
func (l *P2PHandshaked) EventName() string