zlog

package
v0.0.0-...-7f41b1e Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0, MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MockZapLoggerInit

func MockZapLoggerInit()

MockZapLoggerInit for unit test

func S

func S() *zap.SugaredLogger

S for zap Sugar

func ZapLoggerInitByViper

func ZapLoggerInitByViper() error

ZapLoggerInitByViper init zap logger

 viper config example:

	# zap config
	zap:
	  AtomicLevel: -1 # DebugLevel:-1 InfoLevel:0 WarnLevel:1 ErrorLevel:2
	  Api:
	    PrefixPaths: "/api/v1/" # api path prefix list
	    AtomicLevel: 0 # DebugLevel:-1 InfoLevel:0 WarnLevel:1 ErrorLevel:2 default 0
	  FieldsAuto: false # is use auto Fields key set
	  Fields:
	    Key: key
	    Val: val
	  Development: true #  is open file and line number
	  Encoding: console # output format, only use console or json, default is console
	  rotate:
	    Filename: logs/temp-gin-web.log # Log file path
	    # AccessFilename: logs/access.log # Access log file path
	    # ApiFilename: logs/api.log # api log file path
	    MaxSize: 16 # Maximum size of each zlog file, Unit: M
	    MaxBackups: 10 # How many backups are saved in the zlog file
	    MaxAge: 7 # How many days can the file be keep, Unit: day
	    Compress: true # need compress
	  EncoderConfig:
	    TimeKey: time
	    LevelKey: level
	    NameKey: logger
	    CallerKey: caller
	    MessageKey: msg
	    StacktraceKey: stacktrace
	    TimeEncoder: ISO8601TimeEncoder # ISO8601TimeEncoder EpochMillisTimeEncoder EpochNanosTimeEncoder EpochTimeEncoder default is ISO8601TimeEncoder
	    EncodeDuration: SecondsDurationEncoder # NanosDurationEncoder SecondsDurationEncoder StringDurationEncoder default is SecondsDurationEncoder
	    EncodeLevel: CapitalColorLevelEncoder # CapitalLevelEncoder CapitalColorLevelEncoder LowercaseColorLevelEncoder LowercaseLevelEncoder default is CapitalLevelEncoder
	    EncodeCaller: ShortCallerEncoder # ShortCallerEncoder FullCallerEncoder default is FullCallerEncoder

return error

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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