Documentation
¶
Index ¶
- func Debug(ctx context.Context, msg string, tags ...any)
- func Debugf(ctx context.Context, format string, v ...any)
- func Error(ctx context.Context, msg string, tags ...any)
- func Errorf(ctx context.Context, format string, v ...any)
- func Fatal(ctx context.Context, msg string, tags ...any)
- func Fatalf(ctx context.Context, format string, v ...any)
- func Info(ctx context.Context, msg string, tags ...any)
- func Infof(ctx context.Context, format string, v ...any)
- func Warn(ctx context.Context, msg string, tags ...any)
- func Warnf(ctx context.Context, format string, v ...any)
- func WithFixedLogger(ctx context.Context, logger Logger) context.Context
- func WithLogger(ctx context.Context, logger Logger) context.Context
- func Write(ctx context.Context, msg string)
- type Config
- type Logger
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Fatalf ¶ added in v1.16.0
Fatalf logs a formatted message with fatal level and exits the program.
func WithFixedLogger ¶ added in v1.16.0
WithFixedLogger returns a new context with the given fixed logger. This is only used for testing.
func WithLogger ¶ added in v1.16.0
WithLogger returns a new context with the given logger.
Types ¶
type Logger ¶
type Logger interface { Debug(msg string, tags ...any) Info(msg string, tags ...any) Warn(msg string, tags ...any) Error(msg string, tags ...any) Fatal(msg string, tags ...any) Debugf(format string, v ...any) Infof(format string, v ...any) Warnf(format string, v ...any) Errorf(format string, v ...any) Fatalf(format string, v ...any) With(attrs ...any) Logger WithGroup(name string) Logger // Write writes a message to the logger in free form. Write(string) }
func FromContext ¶ added in v1.16.0
FromContext returns a logger from the given context.
type Option ¶ added in v1.16.0
type Option func(*Config)
func WithDebug ¶ added in v1.16.0
func WithDebug() Option
WithDebug sets the level of the logger to debug.
func WithFormat ¶ added in v1.16.0
WithFormat sets the format of the logger (text or json).
func WithWriter ¶ added in v1.16.0
WithWriter sets the file to write logs to.
Click to show internal directories.
Click to hide internal directories.