Documentation
¶
Overview ¶
Package logf contains logging registry & extensions based on stdlib "log".
Index ¶
- Variables
- func Debugf(ctx context.Context, pattern string, values ...any)
- func Errorf(ctx context.Context, pattern string, values ...any)
- func ForEach(f func(name string, logger Interface) bool)
- func Infof(ctx context.Context, pattern string, values ...any)
- func Panicf(ctx context.Context, pattern string, values ...any)
- func Printf(ctx context.Context, pattern string, values ...any)
- func ResetFactory(factory Factory)
- func ResetLevel(level Level)
- func Resultf(ctx context.Context, ok, bad Level, pattern string, values ...any)
- func Tracef(ctx context.Context, pattern string, values ...any)
- func Warnf(ctx context.Context, pattern string, values ...any)
- type Bare
- type BareAdapter
- func (a *BareAdapter) Debugf(ctx context.Context, pattern string, values ...any)
- func (a *BareAdapter) Errorf(ctx context.Context, pattern string, values ...any)
- func (a *BareAdapter) Infof(ctx context.Context, pattern string, values ...any)
- func (a *BareAdapter) Level() Level
- func (a *BareAdapter) Logf(ctx context.Context, level Level, pattern string, values ...any)
- func (a *BareAdapter) Panic(ctx context.Context, value any)
- func (a *BareAdapter) Panicf(ctx context.Context, pattern string, values ...any)
- func (a *BareAdapter) Printf(ctx context.Context, pattern string, values ...any)
- func (a *BareAdapter) Resultf(ctx context.Context, ok, bad Level, pattern string, values ...any)
- func (a *BareAdapter) SetLevel(level Level)
- func (a *BareAdapter) Tracef(ctx context.Context, pattern string, values ...any)
- func (a *BareAdapter) Warnf(ctx context.Context, pattern string, values ...any)
- type Factory
- type Interface
- type Level
- type OutputSetter
- type StdLogger
Constants ¶
This section is empty.
Variables ¶
View Source
var Colored = true
Colored should be set if colored logging output is desired (colors are used for levels and context IDs).
Functions ¶
func ResetFactory ¶
func ResetFactory(factory Factory)
ResetFactory sets logger factory and removes all registered loggers.
Types ¶
type BareAdapter ¶
type BareAdapter struct {
Bare
// contains filtered or unexported fields
}
BareAdapter is adapter for Bare to match Interface.
func (*BareAdapter) Debugf ¶
func (a *BareAdapter) Debugf(ctx context.Context, pattern string, values ...any)
func (*BareAdapter) Errorf ¶
func (a *BareAdapter) Errorf(ctx context.Context, pattern string, values ...any)
func (*BareAdapter) Infof ¶
func (a *BareAdapter) Infof(ctx context.Context, pattern string, values ...any)
func (*BareAdapter) Level ¶
func (a *BareAdapter) Level() Level
func (*BareAdapter) Panicf ¶
func (a *BareAdapter) Panicf(ctx context.Context, pattern string, values ...any)
func (*BareAdapter) Printf ¶
func (a *BareAdapter) Printf(ctx context.Context, pattern string, values ...any)
func (*BareAdapter) SetLevel ¶
func (a *BareAdapter) SetLevel(level Level)
type Interface ¶
type Interface interface {
// SetLevel sets level for this logger.
SetLevel(level Level)
// Level returns current logging level.
Level() Level
// Logf logs the message with specified level.
Logf(ctx context.Context, level Level, pattern string, values ...any)
// Resultf uses `ok` level if the last argument is nil or `bad` level if the last argument is non-nil error.
Resultf(ctx context.Context, ok, bad Level, pattern string, values ...any)
// Printf prints log message with arguments.
Printf(ctx context.Context, pattern string, values ...any)
// Tracef prints log message with Trace level.
Tracef(ctx context.Context, pattern string, values ...any)
// Debugf prints log message with Debug level.
Debugf(ctx context.Context, pattern string, values ...any)
// Infof prints log message with Info level.
Infof(ctx context.Context, pattern string, values ...any)
// Warnf prints log message with Warn level.
Warnf(ctx context.Context, pattern string, values ...any)
// Errorf prints log message with Error level.
Errorf(ctx context.Context, pattern string, values ...any)
// Panicf prints log message with Panic level and panics.
// This behavior is inherent in Resultf if `bad` == Panic.
Panicf(ctx context.Context, pattern string, values ...any)
// Panic prints error and panics.
Panic(ctx context.Context, value any)
}
Interface is the main logger interface. Note that Interface instances should not be kept, but instead always got from Get.
type Level ¶
type Level int8
Level is the logging level.
func (Level) MarshalJSON ¶
func (Level) MarshalYAML ¶
func (*Level) UnmarshalJSON ¶
type OutputSetter ¶
OutputSetter is a logger which supports resetting output.
Click to show internal directories.
Click to hide internal directories.