Documentation ¶
Index ¶
- func GetLoger() *zap.Logger
- func NewCtxZapLoger(optApply ...OptionFunc)
- type CtxZapLogger
- func (l *CtxZapLogger) GetCoresOption() zap.Option
- func (l *CtxZapLogger) GetCtx(ctx context.Context) *zap.Logger
- func (l *CtxZapLogger) GetLogLevel() (level zapcore.Level)
- func (l *CtxZapLogger) SetFileSyncer()
- func (l *CtxZapLogger) Sync() error
- func (l *CtxZapLogger) WithContext(ctx context.Context) *zap.Logger
- func (l *CtxZapLogger) WithContextAndFields(ctx context.Context, field ...zap.Field) (context.Context, *zap.Logger)
- type Option
- type OptionFunc
- func SetAppName(appName string) OptionFunc
- func SetDevelopment(development bool) OptionFunc
- func SetLevel(level string) OptionFunc
- func SetLogCompress(isOn bool) OptionFunc
- func SetLogFileDir(logFileDir string) OptionFunc
- func SetMaxAge(maxAge int) OptionFunc
- func SetMaxBackups(maxBackups int) OptionFunc
- func SetMaxSize(maxSize int) OptionFunc
- func SetWriteConsole(writeConsole bool) OptionFunc
- func SetWriteFile(writeFile bool) OptionFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CtxZapLogger ¶
type CtxZapLogger struct {
// contains filtered or unexported fields
}
func GetCtxZapLoger ¶
func GetCtxZapLoger() *CtxZapLogger
func (*CtxZapLogger) GetCtx ¶
func (l *CtxZapLogger) GetCtx(ctx context.Context) *zap.Logger
获取带ctx的loger
func (*CtxZapLogger) GetLogLevel ¶
func (l *CtxZapLogger) GetLogLevel() (level zapcore.Level)
从配置文件中获取日志配置等级
func (*CtxZapLogger) Sync ¶
func (l *CtxZapLogger) Sync() error
zap底层 API 可以设置缓存,一般主进程退出前使用defer Sync()将缓存同步到文件中
func (*CtxZapLogger) WithContext ¶
func (l *CtxZapLogger) WithContext(ctx context.Context) *zap.Logger
向logger增加ctx
type OptionFunc ¶
type OptionFunc func(*Option)
func SetAppName ¶
func SetAppName(appName string) OptionFunc
func SetDevelopment ¶
func SetDevelopment(development bool) OptionFunc
func SetLevel ¶
func SetLevel(level string) OptionFunc
func SetLogCompress ¶
func SetLogCompress(isOn bool) OptionFunc
func SetLogFileDir ¶
func SetLogFileDir(logFileDir string) OptionFunc
func SetMaxAge ¶
func SetMaxAge(maxAge int) OptionFunc
func SetMaxBackups ¶
func SetMaxBackups(maxBackups int) OptionFunc
func SetMaxSize ¶
func SetMaxSize(maxSize int) OptionFunc
func SetWriteConsole ¶
func SetWriteConsole(writeConsole bool) OptionFunc
func SetWriteFile ¶
func SetWriteFile(writeFile bool) OptionFunc
Click to show internal directories.
Click to hide internal directories.