logger

package
v0.0.0-...-6789dc4 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2021 License: GPL-3.0, GPL-3.0 Imports: 6 Imported by: 34

Documentation

Overview

Package logger defines a simple logger API with level of logging control.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigLogLevel

type ConfigLogLevel string

ConfigLogLevel can hold a log level in a configuration struct.

func (*ConfigLogLevel) ConfigFromJSONString

func (cll *ConfigLogLevel) ConfigFromJSONString()

func (ConfigLogLevel) Level

func (cll ConfigLogLevel) Level() string

Level returns the log level string held in cll.

func (*ConfigLogLevel) SetFromString

func (cll *ConfigLogLevel) SetFromString(enc string) error

func (*ConfigLogLevel) UnmarshalJSON

func (cll *ConfigLogLevel) UnmarshalJSON(b []byte) error

type Logger

type Logger interface {
	// Re-expose base Output for logging events.
	Output(calldept int, s string) error
	// Errorf logs an error.
	Errorf(format string, v ...interface{})
	// Fatalf logs an error and exits the program with os.Exit(1).
	Fatalf(format string, v ...interface{})
	// PanicStackf logs an error message and a stacktrace, for use
	// in panic recovery.
	PanicStackf(format string, v ...interface{})
	// Infof logs an info message.
	Infof(format string, v ...interface{})
	// Debugf logs a debug message.
	Debugf(format string, v ...interface{})
}

Logger is a simple logger interface with logging at levels.

func NewSimpleLogger

func NewSimpleLogger(w io.Writer, level string) Logger

NewSimpleLogger creates a logger logging only up to the given level. The level can be, in order: "error", "info", "debug". It takes an io.Writer.

func NewSimpleLoggerFromMinimalLogger

func NewSimpleLoggerFromMinimalLogger(minLog MinimalLogger, level string) Logger

NewSimpleLoggerFromMinimalLogger creates a logger logging only up to the given level. The level can be, in order: "error", "info", "debug". It takes a value just implementing stlib Logger.Output().

type MinimalLogger

type MinimalLogger interface {
	Output(calldepth int, s string) error
}

MinimalLogger is the minimal interface required to build a simple logger.

Jump to

Keyboard shortcuts

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