Documentation
¶
Overview ¶
Package logger handles the logging Mailpit now uses slog for logging, but this package provides a logrus-compatible API and formatting to avoid changing all existing log calls and provide backwards compatibility with logrus formatting and features like log levels and file output.
Index ¶
- Variables
- func CleanHTTPIP(s string) string
- func PrettyPrint(i any)
- type Logger
- func (l *Logger) Debug(args ...any)
- func (l *Logger) Debugf(format string, args ...any)
- func (l *Logger) Error(args ...any)
- func (l *Logger) Errorf(format string, args ...any)
- func (l *Logger) Fatal(args ...any)
- func (l *Logger) Fatalf(format string, args ...any)
- func (l *Logger) Info(args ...any)
- func (l *Logger) Infof(format string, args ...any)
- func (l *Logger) Printf(format string, args ...any)
- func (l *Logger) Warn(args ...any)
- func (l *Logger) Warnf(format string, args ...any)
Constants ¶
This section is empty.
Variables ¶
var ( // VerboseLogging for verbose logging VerboseLogging bool // QuietLogging shows only errors QuietLogging bool // NoLogging disables all logging (tests) NoLogging bool // LogFile sets a log file LogFile string )
Functions ¶
func CleanHTTPIP ¶
CleanHTTPIP returns a human-readable address for log output. It translates [::]:<port> to localhost:<port>.
func PrettyPrint ¶
func PrettyPrint(i any)
PrettyPrint prints any value as indented JSON to stdout, for debugging.
Types ¶
type Logger ¶ added in v1.30.0
type Logger struct {
// contains filtered or unexported fields
}
Logger wraps slog.Logger providing a logrus-compatible API
func Log ¶
func Log() *Logger
Log returns the logger instance, initialising it on first call. The level and output destination are determined once from VerboseLogging, QuietLogging, NoLogging, and LogFile at the time of first use.
func (*Logger) Fatal ¶ added in v1.30.0
Fatal logs a message at ERROR level then exits with status 1.
func (*Logger) Fatalf ¶ added in v1.30.0
Fatalf logs a formatted message at ERROR level then exits with status 1.