log

package
v0.3.24 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package log provides logging routines based on slog package.

Index

Constants

View Source
const (
	DebugLevel = slog.LevelDebug
	InfoLevel  = slog.LevelInfo
	WarnLevel  = slog.LevelWarn
	ErrorLevel = slog.LevelError
)

Variables

View Source
var DefaultLogger = slog.Default()

DefaultLogger is the default logger.

Functions

func Debugf

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

Debugf logs a debug message.

func Disable

func Disable()

func Errorf

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

Errorf logs an error message.

func Fatalf

func Fatalf(format string, args ...any)

Fatalf logs a fatal message.

func Infof

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

Infof logs an info message.

func Init

func Init(opts ...Option) error

Init initializes the logger.

func New

func New(enabled bool) logr.Logger

New returns a new logr.Logger.

func NewDefaultLogWriter

func NewDefaultLogWriter(level LogLevel) io.Writer

NewDefaultLogWriter returns a io.Writer that logs to the given logger at the given level.

func Warnf

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

Warnf logs a warning message.

Types

type LogLevel

type LogLevel = slog.Level

type Option

type Option func(*options)

Option is a logger option.

func WithAlsoLogToStderr

func WithAlsoLogToStderr() Option

WithAlsoLogToStderr also logs to stderr.

func WithDevMode

func WithDevMode() Option

WithDevMode sets the logger to development mode. In development mode, the logger logs in human-readable format, the level is set to DebugLevel, and logs are also written to stderr.

func WithLevel

func WithLevel(level LogLevel) Option

WithLevel sets the log level. The default log level is InfoLevel.

Jump to

Keyboard shortcuts

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