Documentation ¶
Index ¶
- Constants
- func InitGlobalConfig(rootPath string, level string, appName string) error
- type EmptyLoggerContext
- func (e *EmptyLoggerContext) Debug(ctx context.Context, msg ...interface{})
- func (e *EmptyLoggerContext) Debugf(ctx context.Context, format string, args ...interface{})
- func (e *EmptyLoggerContext) Error(ctx context.Context, msg ...interface{})
- func (e *EmptyLoggerContext) Errorf(ctx context.Context, format string, args ...interface{})
- func (e *EmptyLoggerContext) GetDebugLog() *zerolog.Event
- func (e *EmptyLoggerContext) GetErrorLog() *zerolog.Event
- func (e *EmptyLoggerContext) GetInfoLog() *zerolog.Event
- func (e *EmptyLoggerContext) GetLoggerConf() LoggerConf
- func (e *EmptyLoggerContext) GetWarnLog() *zerolog.Event
- func (e *EmptyLoggerContext) Info(ctx context.Context, msg ...interface{})
- func (e *EmptyLoggerContext) Infof(ctx context.Context, format string, args ...interface{})
- func (*EmptyLoggerContext) RequestId(requestId string) LoggerContextIface
- func (*EmptyLoggerContext) Tag(tag string) LoggerContextIface
- func (e *EmptyLoggerContext) Warn(ctx context.Context, msg ...interface{})
- func (e *EmptyLoggerContext) Warnf(ctx context.Context, format string, args ...interface{})
- func (*EmptyLoggerContext) WithCaller(skip int) LoggerContextIface
- func (*EmptyLoggerContext) WithCommonFields(fields Fields) LoggerContextIface
- func (*EmptyLoggerContext) WithContext(ctx context.Context) LoggerContextIface
- func (*EmptyLoggerContext) WithFields(fields Fields) LoggerContextIface
- func (*EmptyLoggerContext) WithLogData(logData *LogData) LoggerContextIface
- type Fields
- type LogData
- type LoggerConf
- type LoggerContext
- func (l *LoggerContext) Debug(ctx context.Context, args ...interface{})
- func (l *LoggerContext) Debugf(ctx context.Context, format string, args ...interface{})
- func (l *LoggerContext) Error(ctx context.Context, args ...interface{})
- func (l *LoggerContext) Errorf(ctx context.Context, format string, args ...interface{})
- func (l *LoggerContext) GetDebugLog() *zerolog.Event
- func (l *LoggerContext) GetErrorLog() *zerolog.Event
- func (l *LoggerContext) GetInfoLog() *zerolog.Event
- func (l *LoggerContext) GetLoggerConf() LoggerConf
- func (l *LoggerContext) GetWarnLog() *zerolog.Event
- func (l *LoggerContext) Info(ctx context.Context, args ...interface{})
- func (l *LoggerContext) Infof(ctx context.Context, format string, args ...interface{})
- func (l *LoggerContext) RequestId(requestId string) LoggerContextIface
- func (l *LoggerContext) Tag(tag string) LoggerContextIface
- func (l *LoggerContext) Warn(ctx context.Context, args ...interface{})
- func (l *LoggerContext) Warnf(ctx context.Context, format string, args ...interface{})
- func (l *LoggerContext) WithCaller(skip int) LoggerContextIface
- func (l *LoggerContext) WithCommonFields(commonFields Fields) LoggerContextIface
- func (l *LoggerContext) WithContext(ctx context.Context) LoggerContextIface
- func (l *LoggerContext) WithFields(fields Fields) LoggerContextIface
- func (l *LoggerContext) WithLogData(logData *LogData) LoggerContextIface
- type LoggerContextIface
Constants ¶
View Source
const ( LOGGER_ERR_TYPE = "err" LOGGER_ACCESS_TYPE = "access" LOGGER_BUSINESS_TYPE = "business" FLAG_SERVICE_NAME = ":service_name" FLAG_LOGGER_TYPE = ":logger_type" FLAG_EMPTY = "/:-" )
View Source
const ( LEVEL_DEBUG = uint8(iota) LEVEL_INFO LEVEL_WARN LEVEL_ERROR ZEROLOG_CALLER_SKIP = 3 LOG_CALLER_SKIP = 4 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type EmptyLoggerContext ¶
type EmptyLoggerContext struct { }
func (*EmptyLoggerContext) Debug ¶
func (e *EmptyLoggerContext) Debug(ctx context.Context, msg ...interface{})
func (*EmptyLoggerContext) Debugf ¶
func (e *EmptyLoggerContext) Debugf(ctx context.Context, format string, args ...interface{})
func (*EmptyLoggerContext) Error ¶
func (e *EmptyLoggerContext) Error(ctx context.Context, msg ...interface{})
func (*EmptyLoggerContext) Errorf ¶
func (e *EmptyLoggerContext) Errorf(ctx context.Context, format string, args ...interface{})
func (*EmptyLoggerContext) GetDebugLog ¶
func (e *EmptyLoggerContext) GetDebugLog() *zerolog.Event
func (*EmptyLoggerContext) GetErrorLog ¶
func (e *EmptyLoggerContext) GetErrorLog() *zerolog.Event
func (*EmptyLoggerContext) GetInfoLog ¶
func (e *EmptyLoggerContext) GetInfoLog() *zerolog.Event
func (*EmptyLoggerContext) GetLoggerConf ¶
func (e *EmptyLoggerContext) GetLoggerConf() LoggerConf
func (*EmptyLoggerContext) GetWarnLog ¶
func (e *EmptyLoggerContext) GetWarnLog() *zerolog.Event
func (*EmptyLoggerContext) Info ¶
func (e *EmptyLoggerContext) Info(ctx context.Context, msg ...interface{})
func (*EmptyLoggerContext) Infof ¶
func (e *EmptyLoggerContext) Infof(ctx context.Context, format string, args ...interface{})
func (*EmptyLoggerContext) RequestId ¶
func (*EmptyLoggerContext) RequestId(requestId string) LoggerContextIface
func (*EmptyLoggerContext) Tag ¶
func (*EmptyLoggerContext) Tag(tag string) LoggerContextIface
func (*EmptyLoggerContext) Warn ¶
func (e *EmptyLoggerContext) Warn(ctx context.Context, msg ...interface{})
func (*EmptyLoggerContext) Warnf ¶
func (e *EmptyLoggerContext) Warnf(ctx context.Context, format string, args ...interface{})
func (*EmptyLoggerContext) WithCaller ¶
func (*EmptyLoggerContext) WithCaller(skip int) LoggerContextIface
func (*EmptyLoggerContext) WithCommonFields ¶
func (*EmptyLoggerContext) WithCommonFields(fields Fields) LoggerContextIface
func (*EmptyLoggerContext) WithContext ¶
func (*EmptyLoggerContext) WithContext(ctx context.Context) LoggerContextIface
func (*EmptyLoggerContext) WithFields ¶
func (*EmptyLoggerContext) WithFields(fields Fields) LoggerContextIface
func (*EmptyLoggerContext) WithLogData ¶
func (*EmptyLoggerContext) WithLogData(logData *LogData) LoggerContextIface
type LoggerConf ¶
type LoggerConf struct { LogFilePath string // Log文件全路径 AppName string Level uint8 Caller bool // 是否需要显示Caller,默认false时不显示(注:获取caller会影响性能) HideTime bool // 是否隐藏时间,默认显示 ContextCall func(l *LoggerContext, ctx context.Context) LoggerContextIface }
type LoggerContext ¶
type LoggerContext struct {
// contains filtered or unexported fields
}
func GetAccessLogger ¶
func GetAccessLogger(loggerTag string) (*LoggerContext, error)
func GetBusinessLogger ¶
func GetBusinessLogger(loggerTag string) (*LoggerContext, error)
func GetCustomLogger ¶
func GetCustomLogger(customTag, loggerTag string) (*LoggerContext, error)
func GetErrLogger ¶
func GetErrLogger(loggerTag string) (*LoggerContext, error)
func (*LoggerContext) Debug ¶
func (l *LoggerContext) Debug(ctx context.Context, args ...interface{})
func (*LoggerContext) Debugf ¶
func (l *LoggerContext) Debugf(ctx context.Context, format string, args ...interface{})
func (*LoggerContext) Error ¶
func (l *LoggerContext) Error(ctx context.Context, args ...interface{})
func (*LoggerContext) Errorf ¶
func (l *LoggerContext) Errorf(ctx context.Context, format string, args ...interface{})
func (*LoggerContext) GetDebugLog ¶
func (l *LoggerContext) GetDebugLog() *zerolog.Event
func (*LoggerContext) GetErrorLog ¶
func (l *LoggerContext) GetErrorLog() *zerolog.Event
func (*LoggerContext) GetInfoLog ¶
func (l *LoggerContext) GetInfoLog() *zerolog.Event
func (*LoggerContext) GetLoggerConf ¶
func (l *LoggerContext) GetLoggerConf() LoggerConf
func (*LoggerContext) GetWarnLog ¶
func (l *LoggerContext) GetWarnLog() *zerolog.Event
func (*LoggerContext) Info ¶
func (l *LoggerContext) Info(ctx context.Context, args ...interface{})
func (*LoggerContext) Infof ¶
func (l *LoggerContext) Infof(ctx context.Context, format string, args ...interface{})
func (*LoggerContext) RequestId ¶
func (l *LoggerContext) RequestId(requestId string) LoggerContextIface
func (*LoggerContext) Tag ¶
func (l *LoggerContext) Tag(tag string) LoggerContextIface
func (*LoggerContext) Warn ¶
func (l *LoggerContext) Warn(ctx context.Context, args ...interface{})
func (*LoggerContext) Warnf ¶
func (l *LoggerContext) Warnf(ctx context.Context, format string, args ...interface{})
func (*LoggerContext) WithCaller ¶
func (l *LoggerContext) WithCaller(skip int) LoggerContextIface
func (*LoggerContext) WithCommonFields ¶
func (l *LoggerContext) WithCommonFields(commonFields Fields) LoggerContextIface
用于全局设置logger对象的公共输出字段 例如:logger = logger.WithCommonFields(logger.Fields{"app-name":"project" }) {"level":"info",app-name":"project", "attach":{"process-id":25921,"speed":"33.771µs"},"msg":"for test"}
func (*LoggerContext) WithContext ¶
func (l *LoggerContext) WithContext(ctx context.Context) LoggerContextIface
func (*LoggerContext) WithFields ¶
func (l *LoggerContext) WithFields(fields Fields) LoggerContextIface
用于输出自定义字段,同时又不影响整体的日志格式(将fields中指定的字段及值附加到attach中) {"level":"info","attach":{"process-id":25921,"speed":"33.771µs"},"msg":"for test"}
func (*LoggerContext) WithLogData ¶
func (l *LoggerContext) WithLogData(logData *LogData) LoggerContextIface
此函数为了兼容老的日志
type LoggerContextIface ¶
type LoggerContextIface interface { WithLogData(logData *LogData) LoggerContextIface WithCommonFields(commonFields Fields) LoggerContextIface WithFields(fields Fields) LoggerContextIface WithContext(ctx context.Context) LoggerContextIface Tag(tag string) LoggerContextIface RequestId(requestId string) LoggerContextIface WithCaller(skip int) LoggerContextIface Debug(ctx context.Context, args ...interface{}) Debugf(ctx context.Context, format string, args ...interface{}) Info(ctx context.Context, args ...interface{}) Infof(ctx context.Context, format string, args ...interface{}) Warn(ctx context.Context, args ...interface{}) Warnf(ctx context.Context, format string, args ...interface{}) Error(ctx context.Context, args ...interface{}) Errorf(ctx context.Context, format string, args ...interface{}) GetDebugLog() *zerolog.Event GetInfoLog() *zerolog.Event GetWarnLog() *zerolog.Event GetErrorLog() *zerolog.Event GetLoggerConf() LoggerConf }
Click to show internal directories.
Click to hide internal directories.