logging

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ConsoleTraceLogger implements Logger and writes all log messages to stdout.
	ConsoleTraceLogger = Synchronize(consoleLogger{LevelTrace})

	// ConsoleDebugLogger implements Logger and writes all LevelDebug and above messages to stdout.
	ConsoleDebugLogger = Synchronize(consoleLogger{LevelDebug})

	// ConsoleInfoLogger implements Logger and writes all LevelInfo and above log messages to stdout.
	ConsoleInfoLogger = Synchronize(consoleLogger{LevelInfo})

	// ConsoleWarnLogger implements Logger and writes all LevelWarn and above log messages to stdout.
	ConsoleWarnLogger = Synchronize(consoleLogger{LevelWarn})

	// ConsoleErrorLogger implements Logger and writes all LevelError log messages to stdout.
	ConsoleErrorLogger = Synchronize(consoleLogger{LevelError})

	// NilLogger drops all log messages.
	NilLogger = nilLogger{}
)

Functions

This section is empty.

Types

type LogLevel

type LogLevel int
const (
	LevelTrace LogLevel = iota
	LevelDebug
	LevelInfo
	LevelWarn
	LevelError
	LevelDisable // not supposed to be passed to the Log method.
)

type Logger

type Logger interface {
	// Log is invoked with the log level, the log message, and key/value pairs
	// of any relevant log details. The keys are always strings, while the
	// values are unspecified.
	Log(level LogLevel, text string, args ...interface{})

	// MinLevel returns the minimum level at which the logging is performed.
	// This method must be thread-safe and wait-free even if IsConcurrent returns false.
	MinLevel() LogLevel

	// IsConcurrent returns true iff the logger can be safely concurrently accessed by multiple go-routines.
	IsConcurrent() bool
}

Logger is minimal logging interface designed to be easily adaptable to any logging library.

func Decorate

func Decorate(logger Logger, prefix string, args ...interface{}) Logger

func Synchronize

func Synchronize(logger Logger) Logger

Jump to

Keyboard shortcuts

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