log

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FilepathSplitter       = ","
	DefaultFilepath        = "stdout"
	DefaultMaxFileSize     = 100
	DefaultMaxBackups      = 30
	DefaultMaxAge          = 30
	DefaultDisableCompress = false
)
View Source
const (
	JSONFormat    = "json"
	ConsoleFormat = "console"

	LevelEncoderCapital      = "capital"
	LevelEncoderCapitalColor = "capitalColor"
	LevelEncoderColor        = "color"
	LevelEncoderLowercase    = "lowercase"

	TimeEncoderRFC3339Nano = "rfc3339nano"
	TimeEncoderRFC3339     = "rfc3339"
	TimeEncoderISO8601     = "iso8601"
	TimeEncoderMillis      = "millis"
	TimeEncoderNanos       = "nanos"
	TimeEncoderSecond      = "second"
	TimeEncoderLayout      = "2006-01-02 15:04:05.000000"

	DurationEncoderString = "string"
	DurationEncoderNanos  = "nanos"
	DurationEncoderMillis = "ms"
	DurationEncoderSecond = "second"

	CallerEncoderFull  = "full"
	CallerEncoderShort = "short"

	NameEncoderFull = "full"

	DefaultLevel             = "info"
	DefaultIsDev             = false
	DefaultDisableCaller     = false
	DefaultDisableStacktrace = true // stack core will extract error stack, so zap's stack is useless

	DefaultFormat                  = ConsoleFormat
	DefaultEncoderMessageKey       = "msg"
	DefaultEncoderLevelKey         = "lvl"
	DefaultEncoderNameKey          = "logger"
	DefaultEncoderTimeKey          = "ts"
	DefaultEncoderCallerKey        = "caller"
	DefaultEncoderFunctionKey      = ""
	DefaultEncoderStacktraceKey    = "stacktrace"
	DefaultEncoderSkipLineEncoding = false
	DefaultEncoderLineEnding       = "\n"
	DefaultEncoderLevelEncoder     = LevelEncoderLowercase
	DefaultEncoderTimeEncoder      = TimeEncoderLayout
	DefaultEncoderDurationEncoder  = DurationEncoderString
	DefaultEncoderCallerEncoder    = CallerEncoderShort
	DefaultEncoderNameEncoder      = NameEncoderFull
	DefaultEncoderConsoleSeparator = "\t"
)

Variables

View Source
var (
	DefaultOutputPath      = []string{"stdout"}
	DefaultErrorOutputPath = []string{"stderr"}
)

Functions

func Debug

func Debug(option ...zap.Option) *zap.Logger

func Default

func Default(option ...zap.Option) *zap.Logger

func DefaultConfig

func DefaultConfig() *zap.Config

func DefaultEncoderConfig

func DefaultEncoderConfig() zapcore.EncoderConfig

func HandleZapFields

func HandleZapFields(args []interface{}, additional ...zap.Field) []zap.Field

Types

type Cfg

type Cfg struct {
	Filepath        string `env:"LOG_PATH"             flag-long:"log-path"             yaml:"filepath"        flag-description:"log file path"`
	Format          string `env:"LOG_FORMAT"           flag-long:"log-format"           yaml:"format"          flag-description:"log line format"`
	MaxFileSize     int    `` /* 166-byte string literal not displayed */
	MaxBackups      int    `` /* 143-byte string literal not displayed */
	MaxAge          int    `` /* 197-byte string literal not displayed */
	Level           string `` /* 131-byte string literal not displayed */
	DisableCompress bool   `` /* 146-byte string literal not displayed */
}

func NewCfg

func NewCfg() *Cfg

func (*Cfg) Build

func (c *Cfg) Build(opts ...zap.Option) (*zap.Logger, error)

type Logger added in v0.9.0

type Logger interface {
	Debug(msg string, kvs ...any)
	Info(msg string, kvs ...any)
	Warn(msg string, kvs ...any)
	Error(msg string, err error, kvs ...any)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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