logging

package
v3.0.0-rc67 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 17 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	TimeFormat = "15:04:05.000"

	// ConsoleFormatFull shows a console record as its time, its level and
	// its message.
	ConsoleFormatFull = "full"

	// ConsoleFormatPlain shows a console record as its message alone, as
	// the lines a command prints, with its level before it from the
	// warnings up, for a command whose output tells a story its records
	// are lines of.
	ConsoleFormatPlain = "plain"
)

Logger is the opensvc specific zerolog logger

Variables

View Source
var (
	// WithCaller adds the file:line information of the logger caller
	WithCaller bool
)

Functions

func Configure

func Configure(config Config) error

Configure sets up the logging framework

func DropFields

func DropFields(evt map[string]any) error

DropFields is the FormatPrepare of a console writer showing an entry as its time, its level, its message and its error: it removes the other fields, which the writer separates by a space each, even when it renders them as nothing, padding the line with as many trailing blanks.

func FormatLevel

func FormatLevel(i interface{}) string

func FormatPlainLevel

func FormatPlainLevel(i interface{}) string

FormatPlainLevel is the level of a record in the plain console format: none below the warnings, which read as the lines a command prints.

Types

type Config

type Config struct {
	// WithCaller includes the caller file:line to the records
	WithCaller bool

	// Enable console logging
	WithConsoleLog bool

	// Enable console logging coloring
	WithColor bool

	// ConsoleFormat is the format of the console records:
	// ConsoleFormatFull, the default, or ConsoleFormatPlain.
	ConsoleFormat string

	WithJournald bool
	WithSyslogd  bool

	// LogFile makes the framework log to a file
	LogFile string

	// SessionLogFile logs to a per-sessionid file
	SessionLogFile string

	// Level is the minimum log record level to accept.
	// debug, info, warn[ing], error, fatal, panic
	Level 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
}

Config is the configuration of the zerolog logger and writers

type StdLogger

type StdLogger interface {
	Panic(v ...any)
	Panicln(v ...any)
	Panicf(format string, v ...any)
	Fatal(v ...any)
	Fatalln(v ...any)
	Fatalf(format string, v ...any)
	Print(v ...any)
	Println(v ...any)
	Printf(format string, v ...any)
}

func StandardLogger

func StandardLogger(log zerolog.Logger) StdLogger

Jump to

Keyboard shortcuts

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