Documentation
¶
Index ¶
- type Logger
- func (l Logger) Error(ctx context.Context, msg string, args ...any)
- func (l Logger) Errorf(format string, v ...any)
- func (l Logger) Log() *slog.Logger
- func (l Logger) Print(ctx context.Context, msg string, args ...any)
- func (l Logger) PrintOrErr(ctx context.Context, msg string, err error, args ...any)
- func (l Logger) Printf(format string, v ...any)
- func (l Logger) With(args ...any) Logger
- func (l Logger) WithGroup(name string) Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is a struct for embedding std loggers.
func NewLogger ¶
NewLogger returns new Logger wrapper for slog. verbose sets slog.LevelInfo instead of slog.LevelError. isJson uses slog.JSONHandler instead of slog.TextHandler.
func (Logger) Error ¶
Error logs at slog.LevelError with the given context.
func (Logger) Errorf ¶
Errorf logs at slog.LevelError with the given context with fmt.Sprintf.
func (Logger) Print ¶
Print logs at slog.LevelInfo with the given context.
func (Logger) PrintOrErr ¶
PrintOrErr logs an Error if err is not nil, otherwise logs an Info message with args.
func (Logger) Printf ¶
Printf logs at slog.LevelInfo with the given context with fmt.Sprintf.
func (Logger) With ¶
With returns a Logger that includes the given attributes in each output operation. Arguments are converted to attributes as if by Logger.Log.
func (Logger) WithGroup ¶
WithGroup returns a Logger 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 [Handler.WithGroup] method of the Logger's Handler.)
If name is empty, WithGroup returns the receiver.