Documentation
¶
Index ¶
- Constants
- func Init(opts *Options) error
- func SetLevel(l slog.Level)
- func WithRequestID(ctx context.Context, reqID string) context.Context
- func WithTraceID(ctx context.Context, traceID string) context.Context
- func WithUserID(ctx context.Context, userID string) context.Context
- type Format
- type Options
- type Output
- type ZapHandler
Constants ¶
View Source
const ( TraceIDKey ctxKey = "trace_id" ReqIDKey ctxKey = "request_id" UserIDKey ctxKey = "user_id" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Options ¶
type Options struct {
// Level is the minimum log level to output.
Level slog.Level
// Format specifies the output format (json or text).
Format Format
// Output specifies where to write logs (stdout, stderr, or file).
Output Output
// FilePath is the path to the log file (required if Output is "file").
FilePath string
// Rotation configuration for file output.
MaxSize int // megabytes
MaxBackups int // number of files
MaxAge int // days
Compress bool // compress rotated files
// EnableCaller enables caller reporting.
EnableCaller bool
// EnableStack enables stack trace recording.
EnableStack bool
}
func DefaultOptions ¶
func DefaultOptions() *Options
type ZapHandler ¶
func NewZapHandler ¶
func NewZapHandler(opts *Options, level zap.AtomicLevel) *ZapHandler
Click to show internal directories.
Click to hide internal directories.