Documentation ¶
Index ¶
- func Debug(msg string, keysAndValues ...any)
- func Debugf(template string, args ...any)
- func Error(msg string, keysAndValues ...any)
- func Errorf(template string, args ...any)
- func Info(msg string, keysAndValues ...any)
- func Infof(template string, args ...any)
- func InitSlog(handlers ...slog.Handler)
- func InitZapLogger(conf Config)
- func Panic(msg string, keysAndValues ...any)
- func Panicf(template string, args ...any)
- func SetLogger(l ILogger)
- type Config
- type ILogger
- type LogLevel
- type Option
- func WithFileCompress(compress bool) Option
- func WithFileExtension(fileExtension string) Option
- func WithFileJsonEncoder(isJsonEncoder bool) Option
- func WithFileMaxAge(maxAge uint16) Option
- func WithFileMaxSize(maxSize uint16) Option
- func WithFilename(filename string) Option
- func WithFilenameSuffix(filenameSuffix string) Option
- func WithFilepath(filepath string) Option
- func WithLevel(level LogLevel) Option
- func WithTimeFormat(timeFormat string) Option
- type ZapLogger
- func (zl *ZapLogger) Debug(msg string, keysAndValues ...any)
- func (zl *ZapLogger) Debugc(ctx context.Context, msg string, keysAndValues ...any)
- func (zl *ZapLogger) Debugcf(ctx context.Context, format string, args ...any)
- func (zl *ZapLogger) Debugf(format string, args ...any)
- func (zl *ZapLogger) Error(msg string, keysAndValues ...any)
- func (zl *ZapLogger) Errorc(ctx context.Context, msg string, keysAndValues ...any)
- func (zl *ZapLogger) Errorcf(ctx context.Context, format string, args ...any)
- func (zl *ZapLogger) Errorf(format string, args ...any)
- func (zl *ZapLogger) Info(msg string, keysAndValues ...any)
- func (zl *ZapLogger) Infoc(ctx context.Context, msg string, keysAndValues ...any)
- func (zl *ZapLogger) Infocf(ctx context.Context, format string, args ...any)
- func (zl *ZapLogger) Infof(format string, args ...any)
- func (zl *ZapLogger) Panic(msg string, keysAndValues ...any)
- func (zl *ZapLogger) Panicc(ctx context.Context, msg string, keysAndValues ...any)
- func (zl *ZapLogger) Paniccf(ctx context.Context, format string, args ...any)
- func (zl *ZapLogger) Panicf(format string, args ...any)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitZapLogger ¶
func InitZapLogger(conf Config)
Types ¶
type Config ¶
type Config struct { Level string `mapstructure:"level"` LevelCh chan LogLevel TimeFormat string `mapstructure:"timeFormat"` // 完整的文件路径名 Filepath string `mapstructure:"filepath"` Filename string `mapstructure:"filename"` FilenameSuffix string `mapstructure:"filenameSuffix"` FileExtension string `mapstructure:"fileExtension"` FileJsonEncoder bool `mapstructure:"fileJsonEncoder"` FileMaxSize uint16 `mapstructure:"fileSizeMax"` // 单位是MB 默认值是 10MB FileMaxAge uint16 `mapstructure:"fileAgeMax"` // 留存天数 FileCompress bool `mapstructure:"fileCompress"` // 是否归档压缩 }
type ILogger ¶
type ILogger interface { Panic(msg string, keysAndValues ...any) Panicf(format string, args ...any) Panicc(ctx context.Context, msg string, keysAndValues ...any) Paniccf(ctx context.Context, format string, args ...any) Error(msg string, keysAndValues ...any) Errorf(format string, args ...any) Errorc(ctx context.Context, msg string, keysAndValues ...any) Errorcf(ctx context.Context, format string, args ...any) Info(msg string, keysAndValues ...any) Infof(format string, args ...any) Infoc(ctx context.Context, msg string, keysAndValues ...any) Infocf(ctx context.Context, format string, args ...any) Debug(msg string, keysAndValues ...any) Debugf(format string, args ...any) Debugc(ctx context.Context, msg string, keysAndValues ...any) Debugcf(ctx context.Context, format string, args ...any) }
type Option ¶
type Option func(*Config)
func WithFileExtension ¶
WithFileExtension 文件扩展名 (e.g log、txt)
func WithFileJsonEncoder ¶
WithFileJsonEncoder 输出到文件侧是否启用json格式编码
func WithFilename ¶
WithFilename 文件名(文件前缀), 随机部分 main-service-2023-11-04
func WithFilenameSuffix ¶
WithFilenameSuffix 文件后缀名, 随机部分 main-service-2023-11-04
type ZapLogger ¶
type ZapLogger struct {
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.