log

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2025 License: GPL-3.0 Imports: 8 Imported by: 4

Documentation

Overview

Package log is a temporary package until we forge our log structure.

Index

Constants

View Source
const (
	// ErrorLevel level. Logs. Used for errors that should definitely be noted.
	// Commonly used for hooks to send errors to an error tracking service.
	ErrorLevel = slog.LevelError
	// WarnLevel level. Non-critical entries that deserve eyes.
	WarnLevel = slog.LevelWarn
	// NoticeLevel level. Normal but significant conditions. Conditions that are not error conditions, but that may
	// require special handling. slog doesn't have a Notice level, so we use the average between Info and Warn.
	NoticeLevel = (slog.LevelInfo + slog.LevelWarn) / 2
	// InfoLevel level. General operational entries about what's going on inside the application.
	InfoLevel = slog.LevelInfo
	// DebugLevel level. Usually only enabled when debugging. Very verbose logging.
	DebugLevel = slog.LevelDebug
)

Variables

This section is empty.

Functions

func Debug

func Debug(context context.Context, args ...interface{})

Debug outputs messages with the level DebugLevel (when that is enabled) using the configured logging handler.

func Debugf

func Debugf(context context.Context, format string, args ...interface{})

Debugf outputs messages with the level DebugLevel (when that is enabled) using the configured logging handler.

func Error

func Error(context context.Context, args ...interface{})

Error outputs messages with the level ErrorLevel (when that is enabled) using the configured logging handler.

func Errorf

func Errorf(context context.Context, format string, args ...interface{})

Errorf outputs messages with the level ErrorLevel (when that is enabled) using the configured logging handler.

func Info

func Info(context context.Context, args ...interface{})

Info outputs messages with the level InfoLevel (when that is enabled) using the configured logging handler.

func Infof

func Infof(context context.Context, format string, args ...interface{})

Infof outputs messages with the level InfoLevel (when that is enabled) using the configured logging handler.

func InitJournalHandler

func InitJournalHandler(force bool)

InitJournalHandler makes the log package print to the journal if stderr is connected to the journal.

func IsLevelEnabled

func IsLevelEnabled(level Level) bool

IsLevelEnabled checks if the log level is greater than the level param.

func Notice added in v0.5.0

func Notice(context context.Context, args ...interface{})

Notice outputs messages with the level NoticeLevel (when that is enabled) using the configured logging handler.

func Noticef added in v0.5.0

func Noticef(context context.Context, format string, args ...interface{})

Noticef outputs messages with the level NoticeLevel (when that is enabled) using the configured logging handler.

func SetHandler

func SetHandler(handler Handler)

SetHandler allows to define the default handler function for all log levels.

func SetLevelHandler

func SetLevelHandler(level Level, handler Handler)

SetLevelHandler allows to define the default handler function for a given level.

func SetOutput

func SetOutput(out io.Writer)

SetOutput sets the log output.

func Warning

func Warning(context context.Context, args ...interface{})

Warning outputs messages with the level [WarningLevel] (when that is enabled) using the configured logging handler.

func Warningf

func Warningf(context context.Context, format string, args ...interface{})

Warningf outputs messages with the level [WarningLevel] (when that is enabled) using the configured logging handler.

Types

type Handler

type Handler = func(_ context.Context, _ Level, format string, args ...interface{})

Handler is the log handler function.

type Level

type Level = slog.Level

Level is the log level for the logs.

func GetLevel

func GetLevel() Level

GetLevel gets the standard logger level.

func SetLevel

func SetLevel(level Level) (oldLevel Level)

SetLevel sets the standard logger level.

Jump to

Keyboard shortcuts

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