Documentation ¶
Index ¶
- Constants
- func GetInitialDelay(hour int, minute int, second int) (time.Duration, error)
- func GetLogger(name string) logger.Logger
- func GetLoggerWithOptions(name string, opts ...Option) logger.Logger
- func NewBudiler() *zapLoggerBuilder
- func NewCustomProductionEncoderConfig() zapcore.EncoderConfig
- func NewCustomStdoutEncoderConfig() zapcore.EncoderConfig
- func ZapLogger(name string, opts ...Option) logger.Logger
- type ApplyFunc
- type Option
- func AddCaller() Option
- func Compress(is bool) Option
- func FileName(fileName string) Option
- func LocalDateTime(is bool) Option
- func LogRotate(is bool) Option
- func LogRotateCycle(cycle time.Duration) Option
- func LogRotateInitialDelay(delay time.Duration) Option
- func MaxAge(maxAge int) Option
- func MaxBackups(maxBackups int) Option
- func MaxSize(maxSize int) Option
- func Sampling(is bool) Option
- func WithCaller(caller bool) Option
- func WithCallerSkip(skip int) Option
- func WithCategory(category string) Option
- func WithLevel(level zap.AtomicLevel) Option
- func WithRefPath(logRefPath string) Option
- func WithStackTraceLevel(level zap.AtomicLevel) Option
Constants ¶
const ( // MessageKey zap format message key MessageKey string = "msg" // TimeKey zap format time key TimeKey string = "time" // LevelKey zap format level key LevelKey string = "level" // NameKey zap format name key NameKey string = "logger" // CallerKey zap format caller key CallerKey string = "caller" // StacktraceKey zap format stacktrace key StacktraceKey string = "stacktrace" // LogFormatJSON log output with json type LogFormatJSON string = "json" // LogMaxSize max size of single log file LogMaxSize int = 100 // LogMaxAge max save days of log files LogMaxAge int = 365 // LogMaxBackups max backups of log files LogMaxBackups int = 500 // DefaultLogAggregateDir default directory of log categories DefaultLogAggregateDir string = "logs" // DefaultLogFileSuffix default suffix string of log file DefaultLogFileSuffix string = "log" )
Variables ¶
This section is empty.
Functions ¶
func GetInitialDelay ¶ added in v1.0.7
GetInitialDelay returns the initial logRotateInitialDelay millisecond before the first event is logged. hour: hour of the day minute: minute of the hour second: second of the minute return: logRotateInitialDelay time.Duration of time.Now() and the input parse time. if the input parse time if Before the current time, return the Duration that between the current time and the input parse time add one day.
func GetLoggerWithOptions ¶
GetLoggerWithOptions returns a logger with the given name and options.
func NewBudiler ¶ added in v1.0.9
func NewBudiler() *zapLoggerBuilder
NewBuilder returns a new zapLoggerBuilder.
func NewCustomProductionEncoderConfig ¶
func NewCustomProductionEncoderConfig() zapcore.EncoderConfig
NewCustomProductionEncoderConfig return a custom zapcore encoder config
func NewCustomStdoutEncoderConfig ¶
func NewCustomStdoutEncoderConfig() zapcore.EncoderConfig
NewCustomStdoutEncoderConfig return a custom zapcore encoder config
Types ¶
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option zap logger option interface
func AddCaller ¶ added in v1.0.1
func AddCaller() Option
AddCaller return logger with caller caller is a bool option that determines whether the line number of the caller is logged.
func LocalDateTime ¶
LocalDateTime return logger with localDateTime default is true
func LogRotateCycle ¶ added in v1.0.7
LogRotateCycle return logger with logRotateCycleDuration
func LogRotateInitialDelay ¶ added in v1.0.7
LogRotateInitialDelay return logger with initial logRotateInitialDelay time.Duration if logRotate is true, initialDelay is the time to wait before the first log file rotation. The default is the Duration between time.Now() and the parse time of the time.Now().Hour():59:59.
func MaxBackups ¶ added in v1.0.7
MaxBackups return logger with maxBackups
func MaxSize ¶ added in v1.0.7
MaxSize return logger with maxSize if logRotate is true, maxSize is the maximum size of the log file in megabytes. The default is 100 megabytes.
func WithCaller ¶ added in v1.0.1
WithCaller return logger with caller option caller is a bool option that determines whether the line number of the caller is logged. The default is true.
func WithCallerSkip ¶ added in v1.0.1
WithCallerSkip return logger with caller skip callerSkip is the number of stack frames to ascend, starting from zaplogger.go. The default is 1.
func WithCategory ¶
WithCategory return logger with category
func WithLevel ¶
func WithLevel(level zap.AtomicLevel) Option
WithLevel return logger with the given level default is zap.NewAtomicLevel()
func WithRefPath ¶
WithRefPath return logger with the given ref path
func WithStackTraceLevel ¶ added in v1.0.6
func WithStackTraceLevel(level zap.AtomicLevel) Option
WithStackTraceLevel return logger with stackTraceLevel stackTraceLevel is used to determine whether to include stack trace in the log output. The default is ErrorLevel.