Documentation ¶
Overview ¶
Package logger provides some utility methods based around the standard library's slog.Logger package. The goal is to make it easier to create a new slog.Logger given a set of options. More specfically, within the context of the project, we want to be able to create a new logger based on the config options provided by the user via environment variables or the CLI.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LevelFromString ¶
LevelFromString returns the slog.Level corresponding to the given level string. If the level string is not recognized, slog.LevelInfo is returned.
func NewLogger ¶
NewLogger creates a new slog.Logger based on the provided options.
Format can be one of "pretty", "text", or "json". Defaults to "json". IncludeTime indicates whether to include timestamps in log output. Defaults to false. Level can be one of "debug", "info", "warn", or "error". Defaults to "info". Verbose indicates whether to include source information in log output. Defaults to false.
Types ¶
type HoneybadgerLogger ¶
HoneybadgerLogger is a type that represents a slog with the capability to log messages using the Honeybadger log format.
func (HoneybadgerLogger) Printf ¶
func (l HoneybadgerLogger) Printf(format string, v ...interface{})
Printf logs a formatted message using the HoneybadgerLogger's underlying logger.
type Options ¶
Options represents the configuration options for a logger.
Format defines the format of log output. Valid values are "pretty", "text", and "json".
IncludeTime indicates whether to include timestamps in log output.
Level specifies the log level. Valid values are "debug", "info", "warn", and "error".
Verbose indicates whether to include source information in log output.
Writer is the io.Writer to which log output will be written. This lets us redirect the output to a file, for example.