log

package
v0.37.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: Apache-2.0 Imports: 2 Imported by: 20

Documentation

Overview

Package log allows consumers of the lxkns module to forward logging originating in the lxkns module to whatever logger module they prefer.

The accompanying package github.com/thediveo/lxkns/log/logrus can be used as a simple means to forward all lxkns-originating logging messages to the standard sirupsen/logrus logger instance. YMMV, however.

To forward lxkns-originating log messages to a different logging module only needs an adaptor implementing the Logger interface: it consists of just two methods:

  • Log(level Level, msg string)
  • SetLevel(level Level)

A consumer of the lxkns module then sets her specific logging adapter:

SetLog(myadapter)

An adapter can either forward the SetLevel method, but it is also perfectly fine to ignore these interface calls: this allows keeping separate logging levels for lxkns and the consuming application; for instance, disabling or restricting lxkns logging while still doing verbose application logging.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debugf

func Debugf(format string, args ...interface{})

Debugf logs formatted debug information.

func Debugfn

func Debugfn(fn func() string)

Debugfn logs debugging information from the specified fn producer function.

func Errorf

func Errorf(format string, args ...interface{})

Errorf logs a formatted error.

func Infof

func Infof(format string, args ...interface{})

Infof logs formatted information.

func Infofn

func Infofn(fn func() string)

Infofn logs information from the specified fn producer function.

func LevelEnabled added in v0.26.4

func LevelEnabled(level Level) bool

LevelEnabled takes a logging level and returns true, if this level is enabled. Compared with the *fn logging functions LevelEnabled avoids creating closures and allows optimizing hot paths further at the expense of slightly more elaborate logging calling sites.

func SetLevel

func SetLevel(level Level)

SetLevel sets the logging level for lxkns-internal module logging. Depending on the external logger adapter, the level setting might also be propagated to this external logger.

func SetLogger

func SetLogger(logger Logger)

SetLogger sets the logging adapter to be used. Please note that this is not a multiple Go-routine safe operation, so it should be carried out before spawning any logging Go routines.

func Tracef

func Tracef(format string, args ...interface{})

Tracef logs formatted trace information.

func Tracefn

func Tracefn(fn func() string)

Tracefn logs trace information from the specified fn producer function.

func Warnf

func Warnf(format string, args ...interface{})

Warnf logs a formatted warning.

Types

type Level

type Level uint32

Level defines the representation of a single logging level for the purposes of logging in the lxkns module.

const (
	PanicLevel Level = iota
	FatalLevel
	ErrorLevel
	WarnLevel
	InfoLevel
	DebugLevel
	TraceLevel
)

The available logging levels; please note that lxkns only uses a subset of them. By coincidence, these levels match the logging levels of logrus ;)

type Logger

type Logger interface {
	Log(level Level, msg string)
	SetLevel(level Level)
}

Logger defines the logging interface that lxkns expects of adapters to external logging modules.

Directories

Path Synopsis
Package logrus enables logging within the lxkns module and directs all logging output to the sirupsen/logrus logging module.
Package logrus enables logging within the lxkns module and directs all logging output to the sirupsen/logrus logging module.

Jump to

Keyboard shortcuts

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