logutil

package
v3.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2021 License: Apache-2.0 Imports: 11 Imported by: 56

Documentation

Overview

Package logutil includes utilities to facilitate logging.

Index

Constants

This section is empty.

Variables

View Source
var DefaultLogLevel = "info"
View Source
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:     zapcore.ISO8601TimeEncoder,
		EncodeDuration: zapcore.StringDurationEncoder,
		EncodeCaller:   zapcore.ShortCallerEncoder,
	},

	OutputPaths:      []string{"stderr"},
	ErrorOutputPaths: []string{"stderr"},
}

DefaultZapLoggerConfig defines default zap logger configuration.

Functions

func ConvertToZapLevel

func ConvertToZapLevel(lvl string) zapcore.Level

ConvertToZapLevel converts log level string to zapcore.Level.

func MergeOutputPaths

func MergeOutputPaths(cfg zap.Config) zap.Config

MergeOutputPaths merges logging output paths, resolving conflicts.

func NewJournalWriter

func NewJournalWriter(wr io.Writer) (io.Writer, error)

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

Types

This section is empty.

Jump to

Keyboard shortcuts

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