Documentation
¶
Overview ¶
nolint:err113
Index ¶
- Constants
- func LogLevelFuncForError(err error, logger Logger) func(ctx context.Context, message any, fields ...Field)
- func StdLoggerWithLevel(adapter Logger, level Level, withFields ...Field) *stdlog.Logger
- func ToContext(ctx context.Context, fields ...Field) context.Context
- type Adapter
- func (l *Adapter) Close() error
- func (l *Adapter) Debug(ctx context.Context, msg any, fields ...Field)
- func (l *Adapter) Error(ctx context.Context, msg any, fields ...Field)
- func (l *Adapter) Fatal(ctx context.Context, msg any, fields ...Field)
- func (l *Adapter) Info(ctx context.Context, msg any, fields ...Field)
- func (l *Adapter) IsLevelEnabled(level Level) bool
- func (l *Adapter) Level() Level
- func (l *Adapter) Log(ctx context.Context, level Level, msg any, fields ...Field)
- func (l *Adapter) Panic(ctx context.Context, msg any, fields ...Field)
- func (l *Adapter) Print(ctx context.Context, msg any, fields ...Field)
- func (l *Adapter) SetLogLevel(lvl Level)
- func (l *Adapter) Trace(ctx context.Context, msg any, fields ...Field)
- func (l *Adapter) Warn(ctx context.Context, msg any, fields ...Field)
- type Config
- type Entry
- type Field
- func Any(name string, value any) Field
- func Bool(name string, value bool) Field
- func ByteString(name string, value []byte) Field
- func Duration(name string, value time.Duration) Field
- func Error(err error) Field
- func Float64(name string, value float64) Field
- func Int(name string, value int) Field
- func Int64(name string, value int64) Field
- func String(name string, value string) Field
- func Stringer(name string, value fmt.Stringer) Field
- func Time(name string, value time.Time) Field
- func Uint(name string, value uint) Field
- func Uint64(name string, value uint64) Field
- type Fields
- type Formatter
- type FormatterConfig
- type FormatterSettings
- type Level
- type LogLevelSpecifier
- type Logger
- type LoggerWriter
- type Option
Constants ¶
View Source
const ( FormatterTypeJson = "json" FormatterTypePlainText = "plain-text" )
View Source
const ( DefaultTimestampFormat = time.RFC3339 FieldKeyMsg = "msg" FieldKeyLevel = "level" FieldKeyTime = "time" FieldKeyLogError = "error" FieldKeyFunc = "func" FieldKeyFile = "file" )
Default field names for the default fields
Variables ¶
This section is empty.
Functions ¶
func LogLevelFuncForError ¶
func LogLevelFuncForError(err error, logger Logger) func(ctx context.Context, message any, fields ...Field)
nolint:exhaustive
func StdLoggerWithLevel ¶
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
func (*Adapter) IsLevelEnabled ¶
func (*Adapter) SetLogLevel ¶ added in v1.5.1
type Config ¶
type Config struct {
Fileoutput *file.Config
Formatter *FormatterConfig
}
type Entry ¶
type Field ¶
func (Field) FormatValue ¶ added in v1.5.0
type FormatterConfig ¶
type FormatterConfig struct {
Type string
Json *FormatterSettings
PlainText *FormatterSettings
}
type FormatterSettings ¶ added in v1.5.0
type Level ¶
type Level uint32
const ( // PanicLevel level, highest level of severity. Logs and then calls panic with the // message passed to Debug, Info, ... PanicLevel Level = iota // FatalLevel level. Logs and then calls `logger.Exit(1)`. It will exit even if the // logging level is set to Panic. FatalLevel // ErrorLevel level. Logs. Used for errors that should definitely be noted. // Commonly used for hooks to send errors to an error tracking service. ErrorLevel // WarnLevel level. Non-critical entries that deserve eyes. WarnLevel // InfoLevel level. General operational entries about what's going on inside the // application. InfoLevel // DebugLevel level. Usually only enabled when debugging. Very verbose logging. DebugLevel // TraceLevel level. Designates finer-grained informational events than the Debug. TraceLevel )
These are the different logging levels. You can set the logging level to log on your instance of logger
func LogLevelForError ¶
func ParseLogLevel ¶
type LogLevelSpecifier ¶
type LogLevelSpecifier interface {
LogLevel() Level
}
type Logger ¶
type Logger interface {
Log(ctx context.Context, level Level, msg any, fields ...Field)
Trace(ctx context.Context, msg any, fields ...Field)
Debug(ctx context.Context, msg any, fields ...Field)
Info(ctx context.Context, msg any, fields ...Field)
Warn(ctx context.Context, msg any, fields ...Field)
Error(ctx context.Context, msg any, fields ...Field)
Fatal(ctx context.Context, msg any, fields ...Field)
Panic(ctx context.Context, msg any, fields ...Field)
}
type LoggerWriter ¶
type LoggerWriter struct {
// contains filtered or unexported fields
}
type Option ¶ added in v1.4.0
type Option func(*Adapter)
func WithExitFunction ¶ added in v1.4.0
func WithExitFunction(f exitFunc) Option
func WithFormatter ¶ added in v1.4.0
func WithOutput ¶ added in v1.4.0
func WithReportCaller ¶ added in v1.4.0
Source Files
¶
Click to show internal directories.
Click to hide internal directories.