log

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FilepathSplitter   = ","
	DefaultFilepath    = "stdout"
	DefaultMaxFileSize = 100
	DefaultMaxBackups  = 30
	DefaultMaxAge      = 30
	DefaultCompress    = true
)
View Source
const (
	JSONEncoding    = "json"
	ConsoleEncoding = "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             = zap.InfoLevel
	DefaultIsDev             = false
	DefaultDisableCaller     = false
	DefaultDisableStacktrace = true // stack core will extract error stack, so zap's stack is useless

	DefaultEncoding                = ConsoleEncoding
	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"          yaml:"filepath"`
	Encoding    string        `env:"LOG_ENCODING"      yaml:"encoding"`
	MaxFileSize int           `env:"LOG_MAX_FILE_SIZE" yaml:"maxFileSize"`
	MaxBackups  int           `env:"LOG_MAX_BACKUPS"   yaml:"maxBackups"`
	MaxAge      int           `env:"LOG_MAX_AGE"       yaml:"maxAge"`
	Level       zapcore.Level `env:"LOG_LEVEL"         yaml:"level"`
	Compress    bool          `env:"LOG_COMPRESS"      yaml:"compress"`
}

func NewCfg

func NewCfg() *Cfg

func (*Cfg) Build

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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