Documentation
¶
Index ¶
- func Debug(ctx context.Context, format string, args ...any)
- func Error(ctx context.Context, format string, args ...any)
- func Fatal(ctx context.Context, format string, args ...any)
- func Info(ctx context.Context, format string, args ...any)
- func Log(ctx context.Context, level Level, format string, args ...any)
- func Notice(ctx context.Context, format string, args ...any)
- func Panic(ctx context.Context, format string, args ...any)
- func SetDefault(l Logger)
- func Trace(ctx context.Context, format string, args ...any)
- func Warn(ctx context.Context, format string, args ...any)
- type Handler
- type Handlers
- type Level
- type LevelProvider
- type Logger
- type Option
- type Record
- type Replacer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetDefault ¶
func SetDefault(l Logger)
Types ¶
type Handler ¶
type Handler interface {
// Output output the log Record.
//
// 输出日志.
Output(Record)
}
Handler handles log record, output it to somewhere.
处理日志的接口.
func CombineHandlers ¶ added in v0.0.2
func NewHandler ¶
NewHandler create a new Handler with Info level by default.
创建一个日志处理器, 默认日志级别是 Info.
type LevelProvider ¶ added in v0.0.2
type Logger ¶
type Logger interface {
With(key, value any) Logger
Trace(ctx context.Context, format string, args ...any)
Debug(ctx context.Context, format string, args ...any)
Info(ctx context.Context, format string, args ...any)
Notice(ctx context.Context, format string, args ...any)
Warn(ctx context.Context, format string, args ...any)
Error(ctx context.Context, format string, args ...any)
Panic(ctx context.Context, format string, args ...any)
Fatal(ctx context.Context, format string, args ...any)
// Log 打印日志接口
// callDepth: 0=caller position
Log(ctx context.Context, callDepth int, level Level, format string, args ...any)
}
type Option ¶
type Option func(*handler)
Option Handler options.
日志处理器的配置选项.
func WithJSON ¶ added in v0.0.2
func WithJSON() Option
WithJSON output the log as json format.
JSON 格式输出.
func WithJson ¶
WithJson is a option. output the log as json format if this option is true.
是否以 json 格式输出.
@deprecated use WithJSON instand.
func WithLevels ¶
func WithLevels(levelConfig LevelProvider) Option
WithLevels set log level by package name.
设置不同包的日志级别.
func WithNoColor ¶ added in v0.0.2
func WithNoColor() Option
WithNoColor disable output color.
禁用日志颜色.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.