Documentation ¶
Index ¶
- Constants
- func Debugf(ctx context.Context, format string, v ...any)
- func Errorf(ctx context.Context, format string, v ...any)
- func Infof(ctx context.Context, format string, v ...any)
- func NewContext(ctx context.Context, logger Logger) context.Context
- func Tracef(ctx context.Context, format string, v ...any)
- func Warnf(ctx context.Context, format string, v ...any)
- type Level
- type Logger
- type SimpleLogger
- func (l *SimpleLogger) Debugf(_ context.Context, format string, v ...any)
- func (l *SimpleLogger) Enabled(_ context.Context, level Level) bool
- func (l *SimpleLogger) Errorf(_ context.Context, format string, v ...any)
- func (l *SimpleLogger) Infof(_ context.Context, format string, v ...any)
- func (l *SimpleLogger) Tracef(_ context.Context, format string, v ...any)
- func (l *SimpleLogger) Warnf(_ context.Context, format string, v ...any)
Constants ¶
View Source
const ( LevelTrace = -8 LevelDebug = -4 LevelInfo = 0 LevelWarn = 4 LevelError = 8 )
Variables ¶
This section is empty.
Functions ¶
func NewContext ¶ added in v0.5.0
NewContext returns a new Context that carries the specified logger.
Types ¶
type Logger ¶
type Logger interface { // Enabled returns if logging at the specified level is enabled. // This can be used to avoid computating an expensive value if it // won't be logged anyway. Enabled(ctx context.Context, level Level) bool // Tracef logs a formatted string at [LevelTrace]. Tracef(ctx context.Context, format string, v ...any) // Debugf logs a formatted string at [LevelDebug]. Debugf(ctx context.Context, format string, v ...any) // Infof logs a formatted string at [LevelInfo]. Infof(ctx context.Context, format string, v ...any) // Warnf logs a formatted string at [LevelWarn]. Warnf(ctx context.Context, format string, v ...any) // Errorf logs a formatted string at [LevelError]. Errorf(ctx context.Context, format string, v ...any) }
var DefaultLogger Logger = &SimpleLogger{}
func FromContext ¶ added in v0.5.0
FromContext returns the Logger value stored in ctx, if any.
type SimpleLogger ¶
type SimpleLogger struct{}
func (*SimpleLogger) Debugf ¶
func (l *SimpleLogger) Debugf(_ context.Context, format string, v ...any)
func (*SimpleLogger) Enabled ¶ added in v0.5.0
func (l *SimpleLogger) Enabled(_ context.Context, level Level) bool
func (*SimpleLogger) Errorf ¶
func (l *SimpleLogger) Errorf(_ context.Context, format string, v ...any)
func (*SimpleLogger) Infof ¶
func (l *SimpleLogger) Infof(_ context.Context, format string, v ...any)
Click to show internal directories.
Click to hide internal directories.