logging

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: GPL-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const (
	CONSOLE = "console"
	JOURNAL = "systemd-journald"
)

Variables

This section is empty.

Functions

func AssertOutput

func AssertOutput(o string) error

AssertOutput returns an error if output is not a valid logger output.

func NewJournaldCore

func NewJournaldCore(identifier string, enab zapcore.LevelEnabler) zapcore.Core

NewJournaldCore returns a zapcore.Core that sends log entries to systemd-journald and uses the given identifier as a prefix for structured logging context that is sent as journal fields.

Types

type Logger

type Logger struct {
	*zap.SugaredLogger
	// contains filtered or unexported fields
}

Logger wraps zap.SugaredLogger and allows to get the interval for periodic logging.

func NewLogger

func NewLogger(base *zap.SugaredLogger, interval time.Duration) *Logger

NewLogger returns a new Logger.

func (*Logger) Interval

func (l *Logger) Interval() time.Duration

Interval returns the interval for periodic logging.

type Logging

type Logging struct {
	// contains filtered or unexported fields
}

Logging implements access to a default logger and named child loggers. Log levels can be configured per named child via Options which, if not configured, fall back on a default log level. Logs either to the console or to systemd-journald.

func NewLogging

func NewLogging(name string, level zapcore.Level, output string, options Options, interval time.Duration) (*Logging, error)

NewLogging takes the name and log level for the default logger, output where log messages are written to, options having log levels for named child loggers and returns a new Logging.

func (*Logging) GetChildLogger

func (l *Logging) GetChildLogger(name string) *Logger

GetChildLogger returns a named child logger. Log levels for named child loggers are obtained from the logging options and, if not found, set to the default log level.

func (*Logging) GetLogger

func (l *Logging) GetLogger() *Logger

GetLogger returns the default logger.

type Options

type Options map[string]zapcore.Level

Options define child loggers with their desired log level.

Jump to

Keyboard shortcuts

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