logging

package
v4.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package cli contains initialisation functions for go-flags and go-logging. It facilitates sharing them between several projects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustGetLogger

func MustGetLogger() *logging.Logger

MustGetLogger is a wrapper around go-logging's function of the same name. It automatically determines a logger name. The logger is registered and will be returned by ModuleLevels().

func MustGetLoggerNamed

func MustGetLoggerNamed(name string) *logging.Logger

MustGetLoggerNamed is like MustGetLogger but lets the caller choose the name.

Types

type LogLevelInfo

type LogLevelInfo interface {
	// ModuleLevels returns the level of all loggers retrieved by MustGetLogger().
	ModuleLevels() map[string]logging.Level
	// SetLevel modifies the level of a specific logger.
	SetLevel(level logging.Level, module string)
}

A LogLevelInfo describes and can modify levels of the set of registered loggers.

func InitFileLogging

func InitFileLogging(stderrVerbosity, fileVerbosity Verbosity, filename string) (LogLevelInfo, error)

InitFileLogging initialises logging backends, both to stderr and to a file. If the file path is empty then it will be ignored.

func InitLogging

func InitLogging(verbosity Verbosity) LogLevelInfo

InitLogging initialises logging backends.

func InitStructuredLogging

func InitStructuredLogging(stderrVerbosity, fileVerbosity Verbosity, filename string, structured bool) (LogLevelInfo, error)

InitStructuredLogging is like InitFileLogging but allows specifying whether the output should be structured as JSON.

func MustInitFileLogging

func MustInitFileLogging(stderrVerbosity, fileVerbosity Verbosity, filename string) LogLevelInfo

MustInitFileLogging is like InitFileLogging but dies on any errors.

func MustInitStructuredLogging

func MustInitStructuredLogging(stderrVerbosity, fileVerbosity Verbosity, filename string, structured bool) LogLevelInfo

MustInitStructuredLogging is like InitStructuredLogging but dies on any errors.

type Verbosity

type Verbosity logging.Level

A Verbosity is used as a flag to define logging verbosity.

const MaxVerbosity Verbosity = Verbosity(logging.DEBUG)

MaxVerbosity is the maximum verbosity we support.

const MinVerbosity Verbosity = Verbosity(logging.ERROR)

MinVerbosity is the maximum verbosity we support.

func (*Verbosity) UnmarshalFlag

func (v *Verbosity) UnmarshalFlag(in string) error

UnmarshalFlag implements flag parsing. It accepts input in three forms: As an integer level, -v 4 (where -v 1 == warning & error only) As a named level, -v debug As a series of flags, -vvv (but note that bare -v does *not* work)

Jump to

Keyboard shortcuts

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