Documentation ¶
Index ¶
- Constants
- func DocsMarkdown() ([]byte, error)
- func NewBenthosLogAdapter(l *slog.Logger) *logHandler
- func Spec() docs.FieldSpecs
- type Config
- type File
- type Logger
- func (l *Logger) Debug(format string, v ...any)
- func (l *Logger) Debugln(message string)
- func (l *Logger) Error(format string, v ...any)
- func (l *Logger) Errorln(message string)
- func (l *Logger) Fatal(format string, v ...any)
- func (l *Logger) Fatalln(message string)
- func (l *Logger) Info(format string, v ...any)
- func (l *Logger) Infoln(message string)
- func (l *Logger) Trace(format string, v ...any)
- func (l *Logger) Traceln(message string)
- func (l *Logger) Warn(format string, v ...any)
- func (l *Logger) Warnln(message string)
- func (l *Logger) With(keyValues ...any) Modular
- func (l *Logger) WithFields(inboundFields map[string]string) Modular
- type Modular
- type PrintFormatter
Constants ¶
const ( LogOff int = 0 LogFatal int = 1 LogError int = 2 LogWarn int = 3 LogInfo int = 4 LogDebug int = 5 LogTrace int = 6 LogAll int = 7 )
Logger level constants.
Variables ¶
This section is empty.
Functions ¶
func DocsMarkdown ¶ added in v4.2.0
DocsMarkdown returns a markdown document for the logger documentation.
func NewBenthosLogAdapter ¶ added in v4.20.0
func Spec ¶
func Spec() docs.FieldSpecs
Spec returns a field spec for the logger configuration fields.
Types ¶
type Config ¶
type Config struct { LogLevel string `yaml:"level"` Format string `yaml:"format"` AddTimeStamp bool `yaml:"add_timestamp"` LevelName string `yaml:"level_name"` MessageName string `yaml:"message_name"` TimestampName string `yaml:"timestamp_name"` StaticFields map[string]string `yaml:"static_fields"` File File `yaml:"file"` }
Config holds configuration options for a logger object.
func FromParsed ¶ added in v4.25.0
func FromParsed(pConf *docs.ParsedConfig) (conf Config, err error)
type File ¶ added in v4.2.0
type File struct { Path string `yaml:"path"` Rotate bool `yaml:"rotate"` RotateMaxAge int `yaml:"rotate_max_age_days"` }
File contains configuration for file based logging.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is an object with support for levelled logging and modular components.
func (*Logger) Fatal ¶ added in v4.25.0
Fatal prints a fatal message to the console. Does NOT cause panic.
type Modular ¶
type Modular interface { WithFields(fields map[string]string) Modular With(keyValues ...any) Modular Fatal(format string, v ...any) Error(format string, v ...any) Warn(format string, v ...any) Info(format string, v ...any) Debug(format string, v ...any) Trace(format string, v ...any) }
Modular is a log printer that allows you to branch new modules.
func New ¶ added in v4.14.0
New returns a new logger from a config, or returns an error if the config is invalid.
func Wrap ¶
func Wrap(l PrintFormatter) Modular
Wrap a PrintFormatter with a log.Modular implementation. Log level is set to INFO, use WrapAtLevel to set this explicitly.
func WrapAtLevel ¶
func WrapAtLevel(l PrintFormatter, level int) Modular
WrapAtLevel wraps a PrintFormatter with a log.Modular implementation with an explicit log level.
type PrintFormatter ¶
PrintFormatter is an interface implemented by standard loggers.