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) 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
- type Fields
- type Formatter
- type FormatterConfig
- type JsonFormatterConfig
- type Level
- type LogLevelSpecifier
- type Logger
- type LoggerWriter
- type MutexWrap
- type Option
Constants ¶
View Source
const FormatterTypeJson = "json"
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 ¶
IsLevelEnabled checks if the log level of the logger is greater than the level param
type Config ¶
type Config struct {
Fileoutput *file.Config
Formatter *FormatterConfig
}
type Entry ¶
type Fields ¶
func ContextLogValues ¶
type FormatterConfig ¶
type FormatterConfig struct {
Type string
Json *JsonFormatterConfig
}
type JsonFormatterConfig ¶ added in v1.4.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.