Documentation
¶
Index ¶
- Constants
- Variables
- type Config
- type Logger
- func (l *Logger) Debug(msg string, args ...any)
- func (l *Logger) DebugContext(ctx context.Context, msg string, args ...any)
- func (l *Logger) Error(msg string, args ...any)
- func (l *Logger) ErrorContext(ctx context.Context, msg string, args ...any)
- func (l *Logger) ErrorContextE(ctx context.Context, msg string, err error, args ...any)
- func (l *Logger) ErrorE(msg string, err error, args ...any)
- func (l *Logger) Fatal(msg string, args ...any)
- func (l *Logger) FatalContext(ctx context.Context, msg string, args ...any)
- func (l *Logger) FatalContextE(ctx context.Context, msg string, err error, args ...any)
- func (l *Logger) FatalE(msg string, err error, args ...any)
- func (l *Logger) Info(msg string, args ...any)
- func (l *Logger) InfoContext(ctx context.Context, msg string, args ...any)
- func (l *Logger) WithAttrs(attrs ...slog.Attr) *Logger
- func (l *Logger) WithGroup(name string) *Logger
Constants ¶
const ( // LevelDebug specifies debug log level. LevelDebug = "debug" // LevelDebug specifies info log level. LevelInfo = "info" // LevelDebug specifies error log level. LevelError = "error" // LevelDebug specifies fatal log level. LevelFatal = "fatal" // FormatText specifies text output for a logger. FormatText = "text" // FormatText specifies json output for a logger. FormatJSON = "json" // OutputStdOut specifies stdout output for a logger. OutputStdOut = "stdout" // OutputStdErr specifies stderr output for a logger. OutputStdErr = "stderr" )
Variables ¶
var FlagSet = flag.NewFlagSet("corelog", flag.ContinueOnError)
FlagSet is the set of flags used to configure the logging package.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Level specifies the logging level. Level string // Format specifies the output format of the logger. Format string // EnableStackTrace enables logging error stack traces. EnableStackTrace bool // EnableSource enables logging the source location. EnableSource bool // Output specifies the output path for the logger. Output string // Overrides is a mapping of logger names to override configs. Overrides map[string]Config }
Config contains general settings for a logger.
func LoadConfig ¶
func LoadConfig() Config
LoadConfig returns a config with values set from environment variables and cli flags.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is a logger that wraps the slog package.
func NewLoggerWithConfig ¶
NewLoggerWithConfig returns a new logger configured with the given config.
func (*Logger) DebugContext ¶
DebugContext logs a message at debug log level.
func (*Logger) ErrorContext ¶
ErrorContext logs a message at error log level.
func (*Logger) ErrorContextE ¶
ErrorContextE logs a message at error log level with an error stacktrace.
func (*Logger) FatalContext ¶
FatalContext logs a message at fatal log level and calls os.Exit(1).
func (*Logger) FatalContextE ¶
FatalContextE logs a message at fatal log level with an error stacktrace and calls os.Exit(1).
func (*Logger) InfoContext ¶
InfoContext logs a message at info log level.