logging

package
v2.0.0-...-4795d90 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func GetZerologLevel

func GetZerologLevel(logLevel int) zerolog.Level

GetZerologLevel returns log level mapping

func MarshalStack

func MarshalStack(err error) interface{}

func ShortFile

func ShortFile(_ uintptr, file string, line int) string

Types

type LogConfig

type LogConfig struct {
	// Enable console logging
	ConsoleLoggingEnabled bool
	// Log Level
	LogLevel zerolog.Level
	// Prefix
	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

type Logger

type Logger struct {
	*zerolog.Logger
}

func Configure

func Configure(config LogConfig) *Logger

Configure sets up the logging framework

func Get

func Get() *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 (*Logger) SubLogger

func (l *Logger) SubLogger(key string, value string) *Logger

SubLogger adds the field key with val as a string to the logger context and returns sublogger

Jump to

Keyboard shortcuts

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