log

package
v0.18.1 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 13 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseLevel added in v0.18.0

func ParseLevel(s string) (slog.Level, error)

ParseLevel converts a configured log-level string into an slog.Level. It accepts the legacy logrus level names so existing operator configuration keeps working: trace maps to debug, warning to warn, and fatal/panic to error.

func SetEntryInContext added in v0.2.0

func SetEntryInContext(ctx context.Context, e Entry) context.Context

SetEntryInContext stores an Entry in the request context.

Types

type Entry

type Entry interface {
	// Basic Logging Operation
	Debugf(format string, args ...any)
	Infof(format string, args ...any)
	Warnf(format string, args ...any)
	Errorf(format string, args ...any)

	// Attach contextual information to the logging entry
	WithFields(fields map[string]any) Entry

	// SystemErr is a method that disects the error
	// and logs the appropriate level and fields for it.
	SystemErr(err error)
}

Entry is an abstraction to the Logger and the underlying slog logger so that *Logger always creates an Entry copy which ensures no Fields are being overwritten.

func EntryFromContext added in v0.2.0

func EntryFromContext(ctx context.Context) Entry

EntryFromContext returns an Entry that has been stored in the request context. If there is no value for the key or the type assertion fails, it returns a new entry from the provided logger.

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger is the main struct that any athens internal service should use to communicate things.

func New

func New(cloudProvider string, level slog.Level, format string) *Logger

New constructs a new logger based on the environment and the cloud platform it is running on.

func NewWithOutput added in v0.18.0

func NewWithOutput(w io.Writer, cloudProvider string, level slog.Level, format string) *Logger

NewWithOutput is New but writes to the given io.Writer instead of stdout. It is primarily useful for tests that need to capture log output.

func NoOpLogger added in v0.2.0

func NoOpLogger() *Logger

NoOpLogger provides a Logger that does nothing.

func (Logger) Debugf added in v0.18.0

func (e Logger) Debugf(format string, args ...any)

func (Logger) Errorf added in v0.18.0

func (e Logger) Errorf(format string, args ...any)

func (*Logger) Fatalf added in v0.18.0

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

Fatalf logs at the error level and then exits the process. slog has no fatal level, so this preserves logrus.Fatal's exit-after-logging behavior.

func (Logger) Infof added in v0.18.0

func (e Logger) Infof(format string, args ...any)

func (*Logger) StdLogger added in v0.18.0

func (l *Logger) StdLogger(level slog.Level) *stdlog.Logger

StdLogger returns a *log.Logger that routes through this logger's handler at the given level. Used to redirect output from the standard library logger.

func (Logger) SystemErr

func (e Logger) SystemErr(err error)

func (Logger) Warnf added in v0.18.0

func (e Logger) Warnf(format string, args ...any)

func (Logger) WithFields

func (e Logger) WithFields(fields map[string]any) Entry

Jump to

Keyboard shortcuts

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