package logutil
import "go.etcd.io/etcd/client/pkg/v3/logutil"
Package logutil includes utilities to facilitate logging.
Index ¶
- Variables
- func ConvertToZapLevel(lvl string) zapcore.Level
- func CreateDefaultZapLogger(level zapcore.Level) (*zap.Logger, error)
- func MergeOutputPaths(cfg zap.Config) zap.Config
- func NewJournalWriter(wr io.Writer) (io.Writer, error)
Variables ¶
var DefaultLogLevel = "info"
var DefaultZapLoggerConfig = zap.Config{ Level: zap.NewAtomicLevelAt(ConvertToZapLevel(DefaultLogLevel)), Development: false, Sampling: &zap.SamplingConfig{ Initial: 100, Thereafter: 100, }, Encoding: "json", EncoderConfig: zapcore.EncoderConfig{ TimeKey: "ts", LevelKey: "level", NameKey: "logger", CallerKey: "caller", MessageKey: "msg", StacktraceKey: "stacktrace", LineEnding: zapcore.DefaultLineEnding, EncodeLevel: zapcore.LowercaseLevelEncoder, EncodeTime: func(t time.Time, enc zapcore.PrimitiveArrayEncoder) { enc.AppendString(t.Format("2006-01-02T15:04:05.000000Z0700")) }, EncodeDuration: zapcore.StringDurationEncoder, EncodeCaller: zapcore.ShortCallerEncoder, }, OutputPaths: []string{"stderr"}, ErrorOutputPaths: []string{"stderr"}, }
DefaultZapLoggerConfig defines default zap logger configuration.
Functions ¶
func ConvertToZapLevel ¶
ConvertToZapLevel converts log level string to zapcore.Level.
func CreateDefaultZapLogger ¶
CreateDefaultZapLogger creates a logger with default zap configuration
func MergeOutputPaths ¶
MergeOutputPaths merges logging output paths, resolving conflicts.
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
Source Files ¶
doc.go log_level.go zap.go zap_journal.go
- Version
- v3.5.18 (latest)
- Published
- Jan 24, 2025
- Platform
- linux/amd64
- Imports
- 12 packages
- Last checked
- 1 month ago –
Tools for package owners.