Documentation
¶
Index ¶
- func Debug(ctx context.Context, msg string, args ...any)
- func Enabled(ctx context.Context, level slog.Level) bool
- func Error(ctx context.Context, msg string, args ...any)
- func From(ctx context.Context) *slog.Logger
- func Info(ctx context.Context, msg string, args ...any)
- func Into(ctx context.Context, logger *slog.Logger) context.Context
- func Log(ctx context.Context, level slog.Level, msg string, args ...any)
- func LogAttrs(ctx context.Context, level slog.Level, msg string, attrs ...slog.Attr)
- func Warn(ctx context.Context, msg string, args ...any)
- func With(ctx context.Context, args ...any) context.Context
- func WithGroup(ctx context.Context, name string) context.Context
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Enabled ¶
Enabled reports whether context.Context emits log records at the given level.
Internally calls slog.Logger.Enabled
func From ¶
From returns the logger from the context
If the context does not contain a logger, a default logger is returned
func Log ¶
Log emits a log record with the current time and the given level and message. The Record's Attrs consist of the Logger's attributes followed by the Attrs specified by args.
The attribute arguments are processed as follows:
- If an argument is an Attr, it is used as is.
- If an argument is a string and this is not the last argument, the following argument is treated as the value and the two are combined into an Attr.
- Otherwise, the argument is treated as a value with key "!BADKEY".
Internally calls slog.Logger.Log
func LogAttrs ¶
LogAttrs is a more efficient version of slog.Logger.Log that accepts only Attrs.
Internally calls slog.Logger.LogAttrs
func With ¶
With returns a context.Context that includes the given attributes in each output operation. Arguments are converted to attributes as if by slog.Logger.Log.
Internally calls slog.Logger.With
func WithGroup ¶
WithGroup returns a context.Context that starts a group, if name is non-empty. The keys of all attributes added to the Logger will be qualified by the given name. (How that qualification happens depends on the slog.Handler.WithGroup method of the Logger's Handler.)
If name is empty, WithGroup returns the receiver.
Internally calls slog.Logger.WithGroup
Types ¶
This section is empty.