Documentation
¶
Index ¶
- Constants
- Variables
- func AnyAttrs(attrs []Attr) []any
- func AnyKey(key string) func(any) Attr
- func AttrKey[K, V any](factory func(K, V) Attr, key K) func(V) Attr
- func BoolKey(key string) func(bool) Attr
- func DurationKey(key string) func(time.Duration) Attr
- func Float64Key(key string) func(float64) Attr
- func IndexLevel(l Level) int
- func Int64Key(key string) func(int64) Attr
- func IntKey(key string) func(int) Attr
- func StringKey(key string) func(string) Attr
- func StringLevel(l Level) string
- func TimeKey(key string) func(time.Time) Attr
- func ToGrpcLoggerV2(logger Logger) grpclog.LoggerV2
- func ToLogr(logger Logger) logr.Logger
- func ToTraceLog(logger Logger) tracelog.Logger
- func ToZap(logger Logger) *zap.Logger
- func Uint64Key(key string) func(uint64) Attr
- func ZapCtx(ctx context.Context) zap.Field
- func ZapSpan(span trace.Span) zap.Field
- type Attr
- type EchoHandler
- type Handler
- type JSONHandler
- type Level
- type Leveler
- type LogProvider
- type LogValuer
- type Logger
- type LoggerCtx
- type Record
- type ReplacerAttr
- type SamplerOption
- type Source
- type TextHandler
- type Value
- type WriteThenAction
Constants ¶
View Source
const ( AttrKeyTime = "time" AttrKeySpanID = "span_id" AttrKeyTraceID = "trace_id" AttrKeyTraceFlags = "trace_flags" AttrKeySource = "source" AttrKeyError = "error" AttrKeyMsg = "msg" AttrKeyLevel = "level" AttrKeyStack = "stack" AttrKeyLoggerName = "logger_name" AttrKeyCallerSkipOffset = "caller_skip_offset" AttrKeyCallerPC = "caller_pc" AttrKeySpan = "span" )
View Source
const ( LevelNameTrace = "trace" LevelNameDebug = "debug" LevelNameInfo = "info" LevelNameWarn = "warn" LevelNameError = "error" LevelNamePanic = "panic" LevelNameFatal = "fatal" )
Variables ¶
View Source
var ( AttrTime = TimeKey(AttrKeyTime) AttrSpanID = StringKey(AttrKeySpanID) AttrTraceID = StringKey(AttrKeyTraceID) AttrTraceFlags = IntKey(AttrKeyTraceFlags) AttrSource = StringKey(AttrKeySource) AttrMsg = StringKey(AttrKeyMsg) AttrLevel = StringKey(AttrKeyLevel) AttrStack = StringKey(AttrKeyStack) AttrLoggerName = StringKey(AttrKeyLoggerName) AttrCallerSkipOffset = IntKey(AttrKeyCallerSkipOffset) AttrCallerPC = Int64Key(AttrKeyCallerPC) )
View Source
var ( EmptyAttr = Attr{} Any = slog.Any AnyValue = slog.AnyValue String = slog.String StringValue = slog.StringValue Int64 = slog.Int64 Int64Value = slog.Int64Value Int = slog.Int IntValue = slog.IntValue Uint64 = slog.Uint64 Uint64Value = slog.Uint64Value Float64 = slog.Float64 Float64Value = slog.Float64Value Bool = slog.Bool BoolValue = slog.BoolValue Time = slog.Time TimeValue = slog.TimeValue Duration = slog.Duration DurationValue = slog.DurationValue Group = slog.Group GroupValue = slog.GroupValue )
View Source
var ( LevelTrace = slog.Level(-8) LevelDebug = slog.LevelDebug LevelInfo = slog.LevelInfo LevelWarn = slog.LevelWarn LevelError = slog.LevelError LevelPanic = slog.Level(12) LevelFatal = slog.Level(16) )
View Source
var ( KindAny = slog.KindAny KindBool = slog.KindBool KindDuration = slog.KindDuration KindFloat64 = slog.KindFloat64 KindInt64 = slog.KindInt64 KindString = slog.KindString KindTime = slog.KindTime KindUint64 = slog.KindUint64 KindGroup = slog.KindGroup KindLogValuer = slog.KindLogValuer )
View Source
var ( IgnorePC bool AddSource = true )
View Source
var (
NewRecord = slog.NewRecord
)
Functions ¶
func Float64Key ¶
func StringLevel ¶
func ToGrpcLoggerV2 ¶
func ToTraceLog ¶
Types ¶
type EchoHandler ¶
type EchoHandler struct {
// contains filtered or unexported fields
}
func NewEchoHandler ¶
func NewEchoHandler(ch chan Record) *EchoHandler
func (*EchoHandler) WithAttrs ¶
func (h *EchoHandler) WithAttrs(attrs []Attr) Handler
func (*EchoHandler) WithGroup ¶
func (h *EchoHandler) WithGroup(name string) Handler
type JSONHandler ¶
type JSONHandler = slog.JSONHandler
func NewJSONHandler ¶
func NewJSONHandler(minLevel slog.Leveler, replacerAttrs ...ReplacerAttr) *JSONHandler
type Level ¶
func UnmarshalTextLevel ¶
type LogProvider ¶
type LogProvider interface {
Logger() Logger
}
type Logger ¶
type Logger interface { LogAttrs(ctx context.Context, level Level, msg string, attrs ...Attr) Enabled(Level) bool Debug(ctx context.Context, msg string, attrs ...Attr) Info(ctx context.Context, msg string, attrs ...Attr) Warn(ctx context.Context, msg string, attrs ...Attr) Error(ctx context.Context, msg string, attrs ...Attr) Panic(ctx context.Context, msg string, attrs ...Attr) Fatal(ctx context.Context, msg string, attrs ...Attr) With(attrs ...Attr) Logger Named(string) Logger NewContext(ctx context.Context) context.Context For(ctx context.Context) Logger ForSpan(span trace.Span) Logger Attrs() []Attr Span() trace.Span Handler() Handler }
func NewTextLogger ¶
type ReplacerAttr ¶
func ChainReplacerAttrs ¶
func ChainReplacerAttrs(replacers []ReplacerAttr) ReplacerAttr
type SamplerOption ¶
type SamplerOption func(*sampler)
func WithSamplerLevelThreshold ¶
func WithSamplerLevelThreshold(level Level, n uint64) SamplerOption
func WithSamplerLevelThresholdString ¶
func WithSamplerLevelThresholdString(str string) SamplerOption
type TextHandler ¶
type TextHandler = slog.TextHandler
func NewTextHandler ¶
func NewTextHandler(minLevel slog.Leveler, replacerAttrs ...ReplacerAttr) *TextHandler
type WriteThenAction ¶
type WriteThenAction int
const ( WriteThenUnspecified WriteThenAction = iota WriteThenNoop WriteThenPanic WriteThenFatal )
Source Files
¶
Click to show internal directories.
Click to hide internal directories.