Documentation ¶
Overview ¶
Package logutil includes utilities to facilitate logging.
Index ¶
- func NewGRPCLoggerV2(lcfg zap.Config) (grpclog.LoggerV2, error)
- func NewGRPCLoggerV2FromZapCore(cr zapcore.Core, syncer zapcore.WriteSyncer) grpclog.LoggerV2
- func NewJournalWriter(wr io.Writer) (io.Writer, error)
- func NewRaftLogger(lcfg *zap.Config) (raft.Logger, error)
- func NewRaftLoggerFromZapCore(cr zapcore.Core, syncer zapcore.WriteSyncer) raft.Logger
- type Logger
- type MergeLogger
- func (l *MergeLogger) MergeError(entries ...interface{})
- func (l *MergeLogger) MergeErrorf(format string, args ...interface{})
- func (l *MergeLogger) MergeInfo(entries ...interface{})
- func (l *MergeLogger) MergeInfof(format string, args ...interface{})
- func (l *MergeLogger) MergeNotice(entries ...interface{})
- func (l *MergeLogger) MergeNoticef(format string, args ...interface{})
- func (l *MergeLogger) MergeWarning(entries ...interface{})
- func (l *MergeLogger) MergeWarningf(format string, args ...interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewGRPCLoggerV2 ¶
NewGRPCLoggerV2 converts "*zap.Logger" to "grpclog.LoggerV2". It discards all INFO level logging in gRPC, if debug level is not enabled in "*zap.Logger".
func NewGRPCLoggerV2FromZapCore ¶
NewGRPCLoggerV2FromZapCore creates "grpclog.LoggerV2" from "zap.Core" and "zapcore.WriteSyncer". It discards all INFO level logging in gRPC, if debug level is not enabled in "*zap.Logger".
func NewJournalWriter ¶
NewJournalWriter wraps "io.Writer" to redirect log output to the local systemd journal. If journald send fails, it fails back to writing to the original writer. The decode overhead is only <30µs per write. Reference: https://github.com/coreos/pkg/blob/master/capnslog/journald_formatter.go
func NewRaftLogger ¶
NewRaftLogger converts "*zap.Logger" to "raft.Logger".
func NewRaftLoggerFromZapCore ¶
NewRaftLoggerFromZapCore creates "raft.Logger" from "zap.Core" and "zapcore.WriteSyncer".
Types ¶
type Logger ¶
type Logger interface { grpclog.LoggerV2 // Lvl returns logger if logger's verbosity level >= "lvl". // Otherwise, logger that discards everything. Lvl(lvl int) grpclog.LoggerV2 }
Logger defines logging interface. TODO: deprecate in v3.5.
func NewDiscardLogger ¶
func NewDiscardLogger() Logger
NewDiscardLogger returns a new Logger that discards everything except "fatal".
func NewLogger ¶
NewLogger wraps "grpclog.LoggerV2" that implements "Logger" interface.
For example:
var defaultLogger Logger g := grpclog.NewLoggerV2WithVerbosity(os.Stderr, os.Stderr, os.Stderr, 4) defaultLogger = NewLogger(g)
func NewPackageLogger ¶
NewPackageLogger wraps "*capnslog.PackageLogger" that implements "Logger" interface.
For example:
var defaultLogger Logger defaultLogger = NewPackageLogger("github.com/coreos/etcd", "snapshot")
type MergeLogger ¶
type MergeLogger struct { *capnslog.PackageLogger // contains filtered or unexported fields }
MergeLogger supports merge logging, which merges repeated log lines and prints summary log lines instead.
For merge logging, MergeLogger prints out the line when the line appears at the first time. MergeLogger holds the same log line printed within defaultMergePeriod, and prints out summary log line at the end of defaultMergePeriod. It stops merging when the line doesn't appear within the defaultMergePeriod.
func NewMergeLogger ¶
func NewMergeLogger(logger *capnslog.PackageLogger) *MergeLogger
func (*MergeLogger) MergeError ¶
func (l *MergeLogger) MergeError(entries ...interface{})
func (*MergeLogger) MergeErrorf ¶
func (l *MergeLogger) MergeErrorf(format string, args ...interface{})
func (*MergeLogger) MergeInfo ¶
func (l *MergeLogger) MergeInfo(entries ...interface{})
func (*MergeLogger) MergeInfof ¶
func (l *MergeLogger) MergeInfof(format string, args ...interface{})
func (*MergeLogger) MergeNotice ¶
func (l *MergeLogger) MergeNotice(entries ...interface{})
func (*MergeLogger) MergeNoticef ¶
func (l *MergeLogger) MergeNoticef(format string, args ...interface{})
func (*MergeLogger) MergeWarning ¶
func (l *MergeLogger) MergeWarning(entries ...interface{})
func (*MergeLogger) MergeWarningf ¶
func (l *MergeLogger) MergeWarningf(format string, args ...interface{})