logger

package
v1.5.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2016 License: GPL-3.0 Imports: 10 Imported by: 0

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

Examples

Constants

View Source
const (
	Error = iota + 1
	Warn
	Info
	Core
	Debug
	Detail

	Ridiculousness = 100
)

Variables

This section is empty.

Functions

func AddLogSystem

func AddLogSystem(sys LogSystem)

AddLogSystem starts printing messages to the given LogSystem.

func Flush

func Flush()

Flush waits until all current log messages have been dispatched to the active log systems.

func Reset

func Reset()

Reset removes all active log systems. It blocks until all current messages have been delivered.

Types

type EthChainNewHead

type EthChainNewHead struct {
	BlockHash     string   `json:"block_hash"`
	BlockNumber   *big.Int `json:"block_number"`
	ChainHeadHash string   `json:"chain_head_hash"`
	BlockPrevHash string   `json:"block_prev_hash"`
	LogEvent
}

func (*EthChainNewHead) EventName

func (l *EthChainNewHead) EventName() string

type EthChainReceivedNewBlock

type EthChainReceivedNewBlock struct {
	BlockHash     string   `json:"block_hash"`
	BlockNumber   *big.Int `json:"block_number"`
	ChainHeadHash string   `json:"chain_head_hash"`
	BlockPrevHash string   `json:"block_prev_hash"`
	RemoteId      string   `json:"remote_id"`
	LogEvent
}

func (*EthChainReceivedNewBlock) EventName

func (l *EthChainReceivedNewBlock) EventName() string

type EthMinerNewBlock

type EthMinerNewBlock struct {
	BlockHash     string   `json:"block_hash"`
	BlockNumber   *big.Int `json:"block_number"`
	ChainHeadHash string   `json:"chain_head_hash"`
	BlockPrevHash string   `json:"block_prev_hash"`
	LogEvent
}

func (*EthMinerNewBlock) EventName

func (l *EthMinerNewBlock) EventName() string

type EthTxReceived

type EthTxReceived struct {
	TxHash   string `json:"tx_hash"`
	RemoteId string `json:"remote_id"`
	LogEvent
}

func (*EthTxReceived) EventName

func (l *EthTxReceived) EventName() string

type JsonLog

type JsonLog interface {
	EventName() string
}

type JsonLogger

type JsonLogger struct {
	Coinbase string
}

func NewJsonLogger

func NewJsonLogger() *JsonLogger

func (*JsonLogger) LogJson

func (logger *JsonLogger) LogJson(v JsonLog)

type LogEvent

type LogEvent struct {
	// Guid string      `json:"guid"`
	Ts utctime8601 `json:"ts"`
}

type LogLevel

type LogLevel uint32
const (
	// Standard log levels
	Silence LogLevel = iota
	ErrorLevel
	WarnLevel
	InfoLevel
	DebugLevel
	DebugDetailLevel
)

type LogMsg

type LogMsg interface {
	Level() LogLevel
	fmt.Stringer
}

type LogStarting

type LogStarting struct {
	ClientString    string `json:"client_impl"`
	ProtocolVersion int    `json:"eth_version"`
	LogEvent
}

func (*LogStarting) EventName

func (l *LogStarting) EventName() string

type LogSystem

type LogSystem interface {
	LogPrint(LogMsg)
}

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 New

func New(datadir string, logFile string, logLevel int) LogSystem

func NewJSONsystem

func NewJSONsystem(datadir string, logFile string) LogSystem

func NewJsonLogSystem

func NewJsonLogSystem(writer io.Writer) LogSystem

NewJSONLogSystem creates a LogSystem that prints to the given writer without adding extra information irrespective of loglevel only if message is JSON type

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 NewLogger

func NewLogger(tag string) *Logger

func (*Logger) DebugDetailf

func (logger *Logger) DebugDetailf(format string, v ...interface{})

DebugDetailf writes a message with DebugDetailLevel.

func (*Logger) DebugDetailln

func (logger *Logger) DebugDetailln(v ...interface{})

DebugDetailln writes a message with DebugDetailLevel.

func (*Logger) Debugf

func (logger *Logger) Debugf(format string, v ...interface{})

Debugf writes a message with DebugLevel.

func (*Logger) Debugln

func (logger *Logger) Debugln(v ...interface{})

Debugln writes a message with DebugLevel.

func (*Logger) Errorf

func (logger *Logger) Errorf(format string, v ...interface{})

Errorf writes a message with ErrorLevel.

func (*Logger) Errorln

func (logger *Logger) Errorln(v ...interface{})

Errorln writes a message with ErrorLevel.

func (*Logger) Fatalf

func (logger *Logger) Fatalf(format string, v ...interface{})

Fatalf writes a message with ErrorLevel and exits the program.

func (*Logger) Fatalln

func (logger *Logger) Fatalln(v ...interface{})

Fatalln writes a message with ErrorLevel and exits the program.

func (*Logger) Infof

func (logger *Logger) Infof(format string, v ...interface{})

Infof writes a message with InfoLevel.

func (*Logger) Infoln

func (logger *Logger) Infoln(v ...interface{})

Infoln writes a message with InfoLevel.

func (*Logger) Sendf

func (logger *Logger) Sendf(level LogLevel, format string, v ...interface{})

func (*Logger) Sendln

func (logger *Logger) Sendln(level LogLevel, v ...interface{})

func (*Logger) Warnf

func (logger *Logger) Warnf(format string, v ...interface{})

Warnf writes a message with WarnLevel.

func (*Logger) Warnln

func (logger *Logger) Warnln(v ...interface{})

Warnln writes a message with WarnLevel.

type P2PConnected

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

func (l *P2PConnected) 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 StdLogSystem

type StdLogSystem struct {
	// contains filtered or unexported fields
}

func NewStdLogSystem

func NewStdLogSystem(writer io.Writer, flags int, level LogLevel) *StdLogSystem

NewStdLogSystem creates a LogSystem that prints to the given writer. The flag values are defined package log.

func (*StdLogSystem) GetLogLevel

func (t *StdLogSystem) GetLogLevel() LogLevel

func (*StdLogSystem) LogPrint

func (t *StdLogSystem) LogPrint(msg LogMsg)

func (*StdLogSystem) SetLogLevel

func (t *StdLogSystem) SetLogLevel(i LogLevel)

Directories

Path Synopsis
Package glog implements logging analogous to the Google-internal C++ INFO/ERROR/V setup.
Package glog implements logging analogous to the Google-internal C++ INFO/ERROR/V setup.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL