Documentation ¶
Index ¶
- Variables
- func BuildEncoder(format string) zapcore.Encoder
- func Ctx2Fields(ctx context.Context) []zap.Field
- func Debug(msg string, fields ...zap.Field)
- func DebugCtx(ctx context.Context, msg string, fields ...zap.Field)
- func Error(msg string, fields ...zap.Field)
- func ErrorCtx(ctx context.Context, msg string, fields ...zap.Field)
- func Fatal(msg string, fields ...zap.Field)
- func FatalCtx(ctx context.Context, msg string, fields ...zap.Field)
- func GetLogger() *zap.Logger
- func GetSurgar() *zap.SugaredLogger
- func GinLogger() gin.HandlerFunc
- func GinRecovery(stack bool) gin.HandlerFunc
- func Info(msg string, fields ...zap.Field)
- func InfoCtx(ctx context.Context, msg string, fields ...zap.Field)
- func Interfaces2String(v ...interface{}) string
- func New(cfg *Config)
- func NewOrmLoggerAdapter() xlog.ContextLogger
- func Panic(msg string, fields ...zap.Field)
- func PanicCtx(ctx context.Context, msg string, fields ...zap.Field)
- func Reset(logger *zap.Logger, props *ZapProperties)
- func SetLevel(levelStr string)
- func Sync() error
- func Warn(msg string, fields ...zap.Field)
- func WarnCtx(ctx context.Context, msg string, fields ...zap.Field)
- func With(fields ...zap.Field) *zap.Logger
- type Config
- type ContextLogKey
- type FileLogConfig
- type Level
- type LoggerCtxFunc
- type LoggerFunc
- type OrmCtxLogger
- func (l *OrmCtxLogger) AfterSQL(context xlog.LogContext)
- func (l *OrmCtxLogger) BeforeSQL(context xlog.LogContext)
- func (l *OrmCtxLogger) Debugf(format string, v ...interface{})
- func (l *OrmCtxLogger) Errorf(format string, v ...interface{})
- func (l *OrmCtxLogger) Infof(format string, v ...interface{})
- func (l *OrmCtxLogger) IsShowSQL() bool
- func (l *OrmCtxLogger) Level() xlog.LogLevel
- func (l *OrmCtxLogger) SetLevel(level xlog.LogLevel)
- func (l *OrmCtxLogger) ShowSQL(show ...bool)
- func (l *OrmCtxLogger) Warnf(format string, v ...interface{})
- type OrmLogger
- func (l *OrmLogger) Debug(v ...interface{})
- func (l *OrmLogger) Debugf(format string, v ...interface{})
- func (l *OrmLogger) Error(v ...interface{})
- func (l *OrmLogger) Errorf(format string, v ...interface{})
- func (l *OrmLogger) Info(v ...interface{})
- func (l *OrmLogger) Infof(format string, v ...interface{})
- func (l *OrmLogger) IsShowSQL() bool
- func (l *OrmLogger) Level() xlog.LogLevel
- func (l *OrmLogger) SetLevel(level xlog.LogLevel)
- func (l *OrmLogger) ShowSQL(show ...bool)
- func (l *OrmLogger) Warn(v ...interface{})
- func (l *OrmLogger) Warnf(format string, v ...interface{})
- type OrmLoggerAdapter
- func (l *OrmLoggerAdapter) AfterSQL(ctx xlog.LogContext)
- func (l *OrmLoggerAdapter) BeforeSQL(ctx xlog.LogContext)
- func (l *OrmLoggerAdapter) Debugf(format string, v ...interface{})
- func (l *OrmLoggerAdapter) Errorf(format string, v ...interface{})
- func (l *OrmLoggerAdapter) Infof(format string, v ...interface{})
- func (l *OrmLoggerAdapter) IsShowSQL() bool
- func (l *OrmLoggerAdapter) Level() xlog.LogLevel
- func (l *OrmLoggerAdapter) SetLevel(lv xlog.LogLevel)
- func (l *OrmLoggerAdapter) ShowSQL(show ...bool)
- func (l *OrmLoggerAdapter) Warnf(format string, v ...interface{})
- type ZapProperties
Constants ¶
This section is empty.
Variables ¶
View Source
var ( SessionIDKey = "__xorm_session_id" SessionKey = "__xorm_session_key" SessionShowSQLKey = "__xorm_show_sql" )
Functions ¶
func BuildEncoder ¶
func GetSurgar ¶
func GetSurgar() *zap.SugaredLogger
func GinRecovery ¶
func GinRecovery(stack bool) gin.HandlerFunc
GinRecovery *
- @Description:
- @param stack
- @return gin.HandlerFunc
func Interfaces2String ¶
func Interfaces2String(v ...interface{}) string
func NewOrmLoggerAdapter ¶
func NewOrmLoggerAdapter() xlog.ContextLogger
func Reset ¶
func Reset(logger *zap.Logger, props *ZapProperties)
func SetLevel ¶
func SetLevel(levelStr string)
SetLevel alters the logging level. *
- @Description:
- @param levelStr
Types ¶
type Config ¶
type Config struct { CallSkip int `toml:"callSkip" json:"callSkip"` // Log CallSkip Level string `toml:"level" json:"level"` // Log level. StdLevel string `toml:"stdLevel" json:"stdLevel"` // console level Format string `toml:"format" json:"format"` // Log format. one of json, text, or console. File FileLogConfig `toml:"file" json:"file"` // File log config. }
Config *
- @Description: serializes log related config in toml/json.
type ContextLogKey ¶
type ContextLogKey string
const ( DebugRequestId ContextLogKey = "DebugRequestId" // debug RequestIdKey ContextLogKey = "rid" SessionId ContextLogKey = "sessionId" TraceId ContextLogKey = "traceId" SpanId ContextLogKey = "spanId" ThreadId ContextLogKey = "threadId" Cluster ContextLogKey = "cluster" AppName ContextLogKey = "appName" ServerAddr ContextLogKey = "serverAddr" ServerPort ContextLogKey = "serverPort" Version ContextLogKey = "version" Category ContextLogKey = "logCategory" HttpPath ContextLogKey = "httpPath" //nolint:gosec HttpMethod ContextLogKey = "httpMethod" //nolint:gosec QueryText ContextLogKey = "query" ContentType ContextLogKey = "contentType" StatusCode ContextLogKey = "statusCode" RequestSize ContextLogKey = "requestSize" HttpRequest ContextLogKey = "httpRequest" HttpResponse ContextLogKey = "httpResponse" ClientIp ContextLogKey = "clientIp" UserAgent ContextLogKey = "userAgent" Errors ContextLogKey = "errors" Message ContextLogKey = "msg" BusinessKeyword ContextLogKey = "businessKeyword" BusinessTitle ContextLogKey = "businessTitle" BusinessOperation ContextLogKey = "businessOperation" BusinessUserID ContextLogKey = "businessUserID" Datetime ContextLogKey = "datetime" Caller ContextLogKey = "caller" Duration ContextLogKey = "duration" LevelKey ContextLogKey = "level" )
func (ContextLogKey) ToString ¶
func (key ContextLogKey) ToString() string
type FileLogConfig ¶
type FileLogConfig struct { FileDir string `toml:"fileDir" json:"fileDir"` FileName string `toml:"fileName" json:"fileName"` // Log filename, leave empty to disable file log. MaxSize int `toml:"maxSize" json:"maxSize"` // Max size for a single file, in MB. MaxDays int `toml:"maxDays" json:"maxDays"` // Max log keep days, default is never deleting. MaxBackups int `toml:"maxBackups" json:"maxBackups"` // Maximum number of old log files to retain. Compress bool `toml:"compress" json:"compress"` // Compress }
FileLogConfig *
- @Description: serializes file log related config in toml/json.
type Level ¶
type Level int8
Level is a logging priority. Higher levels are more important.
const ( DebugLevel Level = iota - 1 InfoLevel WarnLevel ErrorLevel CriticalLevel // Critical exists only for config backward compatibility. )
Logging levels.
type LoggerFunc ¶
type OrmCtxLogger ¶
type OrmCtxLogger struct {
// contains filtered or unexported fields
}
func (*OrmCtxLogger) AfterSQL ¶
func (l *OrmCtxLogger) AfterSQL(context xlog.LogContext)
func (*OrmCtxLogger) BeforeSQL ¶
func (l *OrmCtxLogger) BeforeSQL(context xlog.LogContext)
func (*OrmCtxLogger) Debugf ¶
func (l *OrmCtxLogger) Debugf(format string, v ...interface{})
func (*OrmCtxLogger) Errorf ¶
func (l *OrmCtxLogger) Errorf(format string, v ...interface{})
func (*OrmCtxLogger) Infof ¶
func (l *OrmCtxLogger) Infof(format string, v ...interface{})
func (*OrmCtxLogger) IsShowSQL ¶
func (l *OrmCtxLogger) IsShowSQL() bool
func (*OrmCtxLogger) Level ¶
func (l *OrmCtxLogger) Level() xlog.LogLevel
func (*OrmCtxLogger) SetLevel ¶
func (l *OrmCtxLogger) SetLevel(level xlog.LogLevel)
func (*OrmCtxLogger) ShowSQL ¶
func (l *OrmCtxLogger) ShowSQL(show ...bool)
func (*OrmCtxLogger) Warnf ¶
func (l *OrmCtxLogger) Warnf(format string, v ...interface{})
type OrmLoggerAdapter ¶
type OrmLoggerAdapter struct {
// contains filtered or unexported fields
}
func (*OrmLoggerAdapter) AfterSQL ¶
func (l *OrmLoggerAdapter) AfterSQL(ctx xlog.LogContext)
AfterSQL implements ContextLogger
func (*OrmLoggerAdapter) BeforeSQL ¶
func (l *OrmLoggerAdapter) BeforeSQL(ctx xlog.LogContext)
BeforeSQL implements ContextLogger
func (*OrmLoggerAdapter) Debugf ¶
func (l *OrmLoggerAdapter) Debugf(format string, v ...interface{})
Debugf implements ContextLogger
func (*OrmLoggerAdapter) Errorf ¶
func (l *OrmLoggerAdapter) Errorf(format string, v ...interface{})
Errorf implements ContextLogger
func (*OrmLoggerAdapter) Infof ¶
func (l *OrmLoggerAdapter) Infof(format string, v ...interface{})
Infof implements ContextLogger
func (*OrmLoggerAdapter) IsShowSQL ¶
func (l *OrmLoggerAdapter) IsShowSQL() bool
IsShowSQL implements ContextLogger
func (*OrmLoggerAdapter) Level ¶
func (l *OrmLoggerAdapter) Level() xlog.LogLevel
Level implements ContextLogger
func (*OrmLoggerAdapter) SetLevel ¶
func (l *OrmLoggerAdapter) SetLevel(lv xlog.LogLevel)
SetLevel implements ContextLogger
func (*OrmLoggerAdapter) ShowSQL ¶
func (l *OrmLoggerAdapter) ShowSQL(show ...bool)
ShowSQL implements ContextLogger
func (*OrmLoggerAdapter) Warnf ¶
func (l *OrmLoggerAdapter) Warnf(format string, v ...interface{})
Warnf implements ContextLogger
type ZapProperties ¶
type ZapProperties struct { Core zapcore.Core Syncer zapcore.WriteSyncer Level *Level }
func InitLogger ¶
InitLogger initializes a zap logger.
func InitLoggerWithWriteSyncer ¶
func InitLoggerWithWriteSyncer(cfg *Config, output zapcore.WriteSyncer, opts ...zap.Option) (*zap.Logger, *ZapProperties, error)
InitLoggerWithWriteSyncer initializes a zap logger with specified write syncer.
Click to show internal directories.
Click to hide internal directories.