log

package
v4.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ShortError

func ShortError(err error) zap.Field

ShortError contructs a field which only records the error message without the verbose text (i.e. excludes the stack trace).

Types

type Config

type Config struct {
	// Log level.
	// One of "debug", "info", "warn", "error", "dpanic", "panic", and "fatal".
	Level string `toml:"level" json:"level"`
	// Log filename, leave empty to disable file log.
	File string `toml:"file" json:"file"`
	// Max size for a single file, in MB.
	FileMaxSize int `toml:"max-size" json:"max-size"`
	// Max log keep days, default is never deleting.
	FileMaxDays int `toml:"max-days" json:"max-days"`
	// Maximum number of old log files to retain.
	FileMaxBackups int `toml:"max-backups" json:"max-backups"`
	// Format of the log, one of `text`, `json` or `console`.
	Format string `toml:"format" json:"format"`
}

Config serializes log related config in toml/json.

type Logger

type Logger struct {
	*zap.Logger
}

Logger wraps the zap logger.

func InitAppLogger

func InitAppLogger(cfg *Config) (Logger, *pclog.ZapProperties, error)

InitAppLogger inits the wrapped logger from config.

func NewAppLogger

func NewAppLogger(logger *zap.Logger) Logger

NewAppLogger returns the wrapped logger from config.

func Zap

func Zap() Logger

Zap returns the global logger.

Jump to

Keyboard shortcuts

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