aboutsummaryrefslogtreecommitdiffstats
path: root/logger
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-02-12 01:49:00 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-02-12 01:49:00 +0800
commitdb24fb792cf0dab91bc85e79aecf6758349002a4 (patch)
tree7ca7a1540dbf7226b5812690a0133201095661e7 /logger
parent3d6fd601c5eec13480b6c736f6811b663a885766 (diff)
downloadgo-tangerine-db24fb792cf0dab91bc85e79aecf6758349002a4.tar.gz
go-tangerine-db24fb792cf0dab91bc85e79aecf6758349002a4.tar.zst
go-tangerine-db24fb792cf0dab91bc85e79aecf6758349002a4.zip
Move standard fields to LogEvent
Diffstat (limited to 'logger')
-rw-r--r--logger/loggers.go6
-rw-r--r--logger/types.go314
2 files changed, 150 insertions, 170 deletions
diff --git a/logger/loggers.go b/logger/loggers.go
index fd2a01dfd..147b2b85f 100644
--- a/logger/loggers.go
+++ b/logger/loggers.go
@@ -114,13 +114,15 @@ func (logger *Logger) Fatalf(format string, v ...interface{}) {
os.Exit(0)
}
-type JsonLogger struct{}
+type JsonLogger struct {
+ Coinbase string
+}
func NewJsonLogger() *JsonLogger {
return &JsonLogger{}
}
-func (logger *JsonLogger) LogJson(v LogEvent) {
+func (logger *JsonLogger) LogJson(v JsonLog) {
msgname := v.EventName()
obj := map[string]interface{}{
msgname: v,
diff --git a/logger/types.go b/logger/types.go
index 954a76ba3..f8dcb4e78 100644
--- a/logger/types.go
+++ b/logger/types.go
@@ -11,16 +11,21 @@ func (utctime8601) MarshalJSON() ([]byte, error) {
return []byte(`"` + time.Now().UTC().Format(time.RFC3339Nano)[:26] + `Z"`), nil
}
-type LogEvent interface {
+type JsonLog interface {
EventName() string
}
+type LogEvent struct {
+ Guid string `json:"guid"`
+ Ts utctime8601 `json:"ts"`
+ // Level string `json:"level"`
+}
+
type LogStarting struct {
- ClientString string `json:"version_string"`
- Guid string `json:"guid"`
- Coinbase string `json:"coinbase"`
- ProtocolVersion int `json:"eth_version"`
- Ts utctime8601 `json:"ts"`
+ ClientString string `json:"version_string"`
+ Coinbase string `json:"coinbase"`
+ ProtocolVersion int `json:"eth_version"`
+ LogEvent
}
func (l *LogStarting) EventName() string {
@@ -28,11 +33,10 @@ func (l *LogStarting) EventName() string {
}
type P2PConnecting struct {
- RemoteId string `json:"remote_id"`
- RemoteEndpoint string `json:"remote_endpoint"`
- Guid string `json:"guid"`
- NumConnections int `json:"num_connections"`
- Ts utctime8601 `json:"ts"`
+ RemoteId string `json:"remote_id"`
+ RemoteEndpoint string `json:"remote_endpoint"`
+ NumConnections int `json:"num_connections"`
+ LogEvent
}
func (l *P2PConnecting) EventName() string {
@@ -40,10 +44,9 @@ func (l *P2PConnecting) EventName() string {
}
type P2PConnected struct {
- Guid string `json:"guid"`
- NumConnections int `json:"num_connections"`
- RemoteId string `json:"remote_id"`
- Ts utctime8601 `json:"ts"`
+ NumConnections int `json:"num_connections"`
+ RemoteId string `json:"remote_id"`
+ LogEvent
}
func (l *P2PConnected) EventName() string {
@@ -53,9 +56,8 @@ func (l *P2PConnected) EventName() string {
type P2PHandshaked struct {
RemoteCapabilities []string `json:"remote_capabilities"`
RemoteId string `json:"remote_id"`
- Guid string `json:"guid"`
NumConnections int `json:"num_connections"`
- Ts string `json:"ts"`
+ LogEvent
}
func (l *P2PHandshaked) EventName() string {
@@ -63,10 +65,9 @@ func (l *P2PHandshaked) EventName() string {
}
type P2PDisconnected struct {
- Guid string `json:"guid"`
- NumConnections int `json:"num_connections"`
- RemoteId string `json:"remote_id"`
- Ts utctime8601 `json:"ts"`
+ NumConnections int `json:"num_connections"`
+ RemoteId string `json:"remote_id"`
+ LogEvent
}
func (l *P2PDisconnected) EventName() string {
@@ -74,11 +75,10 @@ func (l *P2PDisconnected) EventName() string {
}
type P2PDisconnecting struct {
- Reason string `json:"reason"`
- RemoteId string `json:"remote_id"`
- Guid string `json:"guid"`
- NumConnections int `json:"num_connections"`
- Ts utctime8601 `json:"ts"`
+ Reason string `json:"reason"`
+ RemoteId string `json:"remote_id"`
+ NumConnections int `json:"num_connections"`
+ LogEvent
}
func (l *P2PDisconnecting) EventName() string {
@@ -86,11 +86,10 @@ func (l *P2PDisconnecting) EventName() string {
}
type P2PDisconnectingBadHandshake struct {
- Reason string `json:"reason"`
- RemoteId string `json:"remote_id"`
- Guid string `json:"guid"`
- NumConnections int `json:"num_connections"`
- Ts utctime8601 `json:"ts"`
+ Reason string `json:"reason"`
+ RemoteId string `json:"remote_id"`
+ NumConnections int `json:"num_connections"`
+ LogEvent
}
func (l *P2PDisconnectingBadHandshake) EventName() string {
@@ -98,11 +97,10 @@ func (l *P2PDisconnectingBadHandshake) EventName() string {
}
type P2PDisconnectingBadProtocol struct {
- Reason string `json:"reason"`
- RemoteId string `json:"remote_id"`
- Guid string `json:"guid"`
- NumConnections int `json:"num_connections"`
- Ts utctime8601 `json:"ts"`
+ Reason string `json:"reason"`
+ RemoteId string `json:"remote_id"`
+ NumConnections int `json:"num_connections"`
+ LogEvent
}
func (l *P2PDisconnectingBadProtocol) EventName() string {
@@ -110,11 +108,10 @@ func (l *P2PDisconnectingBadProtocol) EventName() string {
}
type P2PDisconnectingReputation struct {
- Reason string `json:"reason"`
- RemoteId string `json:"remote_id"`
- Guid string `json:"guid"`
- NumConnections int `json:"num_connections"`
- Ts utctime8601 `json:"ts"`
+ Reason string `json:"reason"`
+ RemoteId string `json:"remote_id"`
+ NumConnections int `json:"num_connections"`
+ LogEvent
}
func (l *P2PDisconnectingReputation) EventName() string {
@@ -122,11 +119,10 @@ func (l *P2PDisconnectingReputation) EventName() string {
}
type P2PDisconnectingDHT struct {
- Reason string `json:"reason"`
- RemoteId string `json:"remote_id"`
- Guid string `json:"guid"`
- NumConnections int `json:"num_connections"`
- Ts utctime8601 `json:"ts"`
+ Reason string `json:"reason"`
+ RemoteId string `json:"remote_id"`
+ NumConnections int `json:"num_connections"`
+ LogEvent
}
func (l *P2PDisconnectingDHT) EventName() string {
@@ -134,11 +130,10 @@ func (l *P2PDisconnectingDHT) EventName() string {
}
type P2PEthDisconnectingBadBlock struct {
- Reason string `json:"reason"`
- RemoteId string `json:"remote_id"`
- Guid string `json:"guid"`
- NumConnections int `json:"num_connections"`
- Ts utctime8601 `json:"ts"`
+ Reason string `json:"reason"`
+ RemoteId string `json:"remote_id"`
+ NumConnections int `json:"num_connections"`
+ LogEvent
}
func (l *P2PEthDisconnectingBadBlock) EventName() string {
@@ -146,11 +141,10 @@ func (l *P2PEthDisconnectingBadBlock) EventName() string {
}
type P2PEthDisconnectingBadTx struct {
- Reason string `json:"reason"`
- RemoteId string `json:"remote_id"`
- Guid string `json:"guid"`
- NumConnections int `json:"num_connections"`
- Ts utctime8601 `json:"ts"`
+ Reason string `json:"reason"`
+ RemoteId string `json:"remote_id"`
+ NumConnections int `json:"num_connections"`
+ LogEvent
}
func (l *P2PEthDisconnectingBadTx) EventName() string {
@@ -158,14 +152,13 @@ func (l *P2PEthDisconnectingBadTx) EventName() string {
}
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"`
- Guid string `json:"guid"`
- BlockPrevHash string `json:"block_prev_hash"`
- Ts utctime8601 `json:"ts"`
+ 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 (l *EthNewBlockMined) EventName() string {
@@ -173,13 +166,12 @@ func (l *EthNewBlockMined) EventName() string {
}
type EthNewBlockBroadcasted struct {
- BlockNumber int `json:"block_number"`
- HeadHash string `json:"head_hash"`
- BlockHash string `json:"block_hash"`
- BlockDifficulty int `json:"block_difficulty"`
- Guid string `json:"guid"`
- BlockPrevHash string `json:"block_prev_hash"`
- Ts utctime8601 `json:"ts"`
+ 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 (l *EthNewBlockBroadcasted) EventName() string {
@@ -187,13 +179,12 @@ func (l *EthNewBlockBroadcasted) EventName() string {
}
type EthNewBlockReceived struct {
- BlockNumber int `json:"block_number"`
- HeadHash string `json:"head_hash"`
- BlockHash string `json:"block_hash"`
- BlockDifficulty int `json:"block_difficulty"`
- Guid string `json:"guid"`
- BlockPrevHash string `json:"block_prev_hash"`
- Ts utctime8601 `json:"ts"`
+ 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 (l *EthNewBlockReceived) EventName() string {
@@ -201,13 +192,12 @@ func (l *EthNewBlockReceived) EventName() string {
}
type EthNewBlockIsKnown struct {
- BlockNumber int `json:"block_number"`
- HeadHash string `json:"head_hash"`
- BlockHash string `json:"block_hash"`
- BlockDifficulty int `json:"block_difficulty"`
- Guid string `json:"guid"`
- BlockPrevHash string `json:"block_prev_hash"`
- Ts utctime8601 `json:"ts"`
+ 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 (l *EthNewBlockIsKnown) EventName() string {
@@ -215,13 +205,12 @@ func (l *EthNewBlockIsKnown) EventName() string {
}
type EthNewBlockIsNew struct {
- BlockNumber int `json:"block_number"`
- HeadHash string `json:"head_hash"`
- BlockHash string `json:"block_hash"`
- BlockDifficulty int `json:"block_difficulty"`
- Guid string `json:"guid"`
- BlockPrevHash string `json:"block_prev_hash"`
- Ts utctime8601 `json:"ts"`
+ 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 (l *EthNewBlockIsNew) EventName() string {
@@ -229,13 +218,12 @@ func (l *EthNewBlockIsNew) EventName() string {
}
type EthNewBlockMissingParent struct {
- BlockNumber int `json:"block_number"`
- HeadHash string `json:"head_hash"`
- BlockHash string `json:"block_hash"`
- BlockDifficulty int `json:"block_difficulty"`
- Guid string `json:"guid"`
- BlockPrevHash string `json:"block_prev_hash"`
- Ts utctime8601 `json:"ts"`
+ 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 (l *EthNewBlockMissingParent) EventName() string {
@@ -243,13 +231,12 @@ func (l *EthNewBlockMissingParent) EventName() string {
}
type EthNewBlockIsInvalid struct {
- BlockNumber int `json:"block_number"`
- HeadHash string `json:"head_hash"`
- BlockHash string `json:"block_hash"`
- BlockDifficulty int `json:"block_difficulty"`
- Guid string `json:"guid"`
- BlockPrevHash string `json:"block_prev_hash"`
- Ts utctime8601 `json:"ts"`
+ 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 (l *EthNewBlockIsInvalid) EventName() string {
@@ -257,13 +244,12 @@ func (l *EthNewBlockIsInvalid) EventName() string {
}
type EthNewBlockChainIsOlder struct {
- BlockNumber int `json:"block_number"`
- HeadHash string `json:"head_hash"`
- BlockHash string `json:"block_hash"`
- BlockDifficulty int `json:"block_difficulty"`
- Guid string `json:"guid"`
- BlockPrevHash string `json:"block_prev_hash"`
- Ts utctime8601 `json:"ts"`
+ 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 (l *EthNewBlockChainIsOlder) EventName() string {
@@ -271,13 +257,12 @@ func (l *EthNewBlockChainIsOlder) EventName() string {
}
type EthNewBlockChainIsCanonical struct {
- BlockNumber int `json:"block_number"`
- HeadHash string `json:"head_hash"`
- BlockHash string `json:"block_hash"`
- BlockDifficulty int `json:"block_difficulty"`
- Guid string `json:"guid"`
- BlockPrevHash string `json:"block_prev_hash"`
- Ts utctime8601 `json:"ts"`
+ 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 (l *EthNewBlockChainIsCanonical) EventName() string {
@@ -285,13 +270,12 @@ func (l *EthNewBlockChainIsCanonical) EventName() string {
}
type EthNewBlockChainNotCanonical struct {
- BlockNumber int `json:"block_number"`
- HeadHash string `json:"head_hash"`
- BlockHash string `json:"block_hash"`
- BlockDifficulty int `json:"block_difficulty"`
- Guid string `json:"guid"`
- BlockPrevHash string `json:"block_prev_hash"`
- Ts utctime8601 `json:"ts"`
+ 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 (l *EthNewBlockChainNotCanonical) EventName() string {
@@ -299,14 +283,13 @@ func (l *EthNewBlockChainNotCanonical) EventName() string {
}
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"`
- Guid string `json:"guid"`
- BlockPrevHash string `json:"block_prev_hash"`
- Ts utctime8601 `json:"ts"`
+ 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 (l *EthNewBlockChainSwitched) EventName() string {
@@ -314,13 +297,12 @@ func (l *EthNewBlockChainSwitched) EventName() string {
}
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"`
- Guid string `json:"guid"`
- Ts utctime8601 `json:"ts"`
+ 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 (l *EthTxCreated) EventName() string {
@@ -328,13 +310,12 @@ func (l *EthTxCreated) EventName() string {
}
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"`
- Guid string `json:"guid"`
- Ts utctime8601 `json:"ts"`
+ 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 (l *EthTxReceived) EventName() string {
@@ -342,12 +323,11 @@ func (l *EthTxReceived) EventName() string {
}
type EthTxBroadcasted struct {
- TxHash string `json:"tx_hash"`
- TxSender string `json:"tx_sender"`
- TxAddress string `json:"tx_address"`
- TxNonce int `json:"tx_nonce"`
- Guid string `json:"guid"`
- Ts utctime8601 `json:"ts"`
+ TxHash string `json:"tx_hash"`
+ TxSender string `json:"tx_sender"`
+ TxAddress string `json:"tx_address"`
+ TxNonce int `json:"tx_nonce"`
+ LogEvent
}
func (l *EthTxBroadcasted) EventName() string {
@@ -355,12 +335,11 @@ func (l *EthTxBroadcasted) EventName() string {
}
type EthTxValidated struct {
- TxHash string `json:"tx_hash"`
- TxSender string `json:"tx_sender"`
- TxAddress string `json:"tx_address"`
- TxNonce int `json:"tx_nonce"`
- Guid string `json:"guid"`
- Ts utctime8601 `json:"ts"`
+ TxHash string `json:"tx_hash"`
+ TxSender string `json:"tx_sender"`
+ TxAddress string `json:"tx_address"`
+ TxNonce int `json:"tx_nonce"`
+ LogEvent
}
func (l *EthTxValidated) EventName() string {
@@ -368,13 +347,12 @@ func (l *EthTxValidated) EventName() string {
}
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"`
- Guid string `json:"guid"`
- Ts utctime8601 `json:"ts"`
+ 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 (l *EthTxIsInvalid) EventName() string {