logging

package
v2.0.0-...-c3aa4fa Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultLogMaxMegaBytes = 10 // 10 MB
	DefaultLogMaxBackups   = 5
	DefaultLogMaxAge       = 7
)

Variables

This section is empty.

Functions

func Configure

func Configure(config LogConfig) *slog.Logger

Configure sets up the logging framework

func Get

func Get() *slog.Logger

Get Returns a logger with default configuration if logger is not initialized yet default configuration only writes to console and not to file see param defaultFileLoggingEnabled

func GetLogLevel

func GetLogLevel(logLevel int) slog.Level

GetLogLevel returns log level mapping

func GetLogPath

func GetLogPath() string

Types

type LogConfig

type LogConfig struct {
	ConsoleLoggingEnabled bool
	LogLevel              slog.Level
	LogFormat             string // one of "plain" or "json"
	PrefixKey             string
	PrefixValue           string
	// FileLoggingEnabled makes the framework log to a file
	FileLoggingEnabled bool
	// Directory to log to when filelogging is enabled
	Directory string
	// Filename is the name of the logfile which will be placed inside the directory
	Filename string
	// MaxSize the max size in MB of the logfile before it's rolled
	MaxSize int
	// MaxBackups the max number of rolled files to keep
	MaxBackups int
	// MaxAge the max age in days to keep a logfile
	MaxAge int
}

LogConfig defines the configuration for logging

Jump to

Keyboard shortcuts

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