logger

package
v1.26.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2025 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NullLogger = nullLogger{}

NullLogger is a logger that does nothing

Functions

func AppendTimestamp added in v1.25.0

func AppendTimestamp(b []byte, t time.Time) []byte

AppendTimestamp appends a timestamp in format "YYYY-MM-DDTHH:mm:ss.sssZ" to the given byte slice and returns the extended slice.

The timestamp is always in UTC and has exactly 3 fractional digits (millisecond precision). Makes no allocations if b has enough capacity.

func Debugf

func Debugf(format string, v ...any)

Debugf records something in the debug log

func MockLogger

func MockLogger(prefix string) (fmt.Stringer, func())

MockLogger replaces the existing logger with a buffer and returns a Stringer returning the log buffer content and a restore function.

func Noticef

func Noticef(format string, v ...any)

Noticef notifies the user of something

func Panicf

func Panicf(format string, v ...any)

Panicf notifies the user and then panics

func SecurityCritical added in v1.24.0

func SecurityCritical(event SecurityEvent, arg, description string)

SecurityCritical logs a security CRITICAL event with the given arguments.

func SecurityWarn added in v1.24.0

func SecurityWarn(event SecurityEvent, arg, description string)

SecurityWarn logs a security WARN event with the given arguments.

func SetAppID added in v1.24.0

func SetAppID(s string)

SetAppID sets the "appid" field used for security logging. The default is "pebble".

Types

type Logger

type Logger interface {
	// Notice is for messages that the user should see
	Notice(msg string)
	// Debug is for messages that the user should be able to find if they're debugging something
	Debug(msg string)
}

A Logger is a fairly minimal logging tool.

func New

func New(w io.Writer, prefix string) Logger

New creates a log.Logger using the given io.Writer and prefix (which is printed between the timestamp and the message).

func SetLogger

func SetLogger(l Logger) (old Logger)

SetLogger sets the global logger to the given one. It must be called from a single goroutine before any logs are written.

type SecurityEvent added in v1.24.0

type SecurityEvent string
const (
	SecurityAuthzAdmin         SecurityEvent = "authz_admin"
	SecurityAuthzFail          SecurityEvent = "authz_fail"
	SecurityUserCreated        SecurityEvent = "user_created"
	SecurityUserDeleted        SecurityEvent = "user_deleted"
	SecurityUserUpdated        SecurityEvent = "user_updated"
	SecuritySysMonitorDisabled SecurityEvent = "sys_monitor_disabled"
	SecuritySysShutdown        SecurityEvent = "sys_shutdown"
	SecuritySysStartup         SecurityEvent = "sys_startup"
)

Jump to

Keyboard shortcuts

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