logger

package
v1.30.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 8 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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

func CleanHTTPIP(s string) string

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) Debug added in v1.30.0

func (l *Logger) Debug(args ...any)

Debug logs a message at DEBUG level.

func (*Logger) Debugf added in v1.30.0

func (l *Logger) Debugf(format string, args ...any)

Debugf logs a formatted message at DEBUG level.

func (*Logger) Error added in v1.30.0

func (l *Logger) Error(args ...any)

Error logs a message at ERROR level.

func (*Logger) Errorf added in v1.30.0

func (l *Logger) Errorf(format string, args ...any)

Errorf logs a formatted message at ERROR level.

func (*Logger) Fatal added in v1.30.0

func (l *Logger) Fatal(args ...any)

Fatal logs a message at ERROR level then exits with status 1.

func (*Logger) Fatalf added in v1.30.0

func (l *Logger) Fatalf(format string, args ...any)

Fatalf logs a formatted message at ERROR level then exits with status 1.

func (*Logger) Info added in v1.30.0

func (l *Logger) Info(args ...any)

Info logs a message at INFO level.

func (*Logger) Infof added in v1.30.0

func (l *Logger) Infof(format string, args ...any)

Infof logs a formatted message at INFO level.

func (*Logger) Printf added in v1.30.0

func (l *Logger) Printf(format string, args ...any)

Printf logs a formatted message at INFO level.

func (*Logger) Warn added in v1.30.0

func (l *Logger) Warn(args ...any)

Warn logs a message at WARN level.

func (*Logger) Warnf added in v1.30.0

func (l *Logger) Warnf(format string, args ...any)

Warnf logs a formatted message at WARN level.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL