loggers

package
v0.0.0-...-760d8ea Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: GPL-3.0 Imports: 5 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Console

type Console interface {
	// Log prints the message to the console.
	Log(level LogLevel, msg string)
}

Console prints an output to a live terminal.

func NewSTDOut

func NewSTDOut() Console

NewSTDOut creates a new Console that writes to the standard outputs defined by the OS.

LogLevelInfo and LogLevelWarning are written to os.Stdout, LogLevelError and LogLevelFatal are written to os.Stderr.

type JSON

type JSON interface {
	// Log sends a JSON representation of the log message.
	Log(level LogLevel, data interface{})
}

JSON sends a serialized JSON representation of the log message.

func NewZeroLog

func NewZeroLog(logger zerolog.Logger) JSON

NewZeroLog creates a new JSON that writes to a zerolog.Logger.

It can make use of messages that implement the ZerologMessage interface.

type LogLevel

type LogLevel string

LogLevel specify the importance of the log message. Some implementations may use different channels depending on the log level.

const (
	// LogLevelInfo is the lowest log level. It is used for general information messages.
	LogLevelInfo LogLevel = "INFO"
	// LogLevelWarning is used for messages that are not errors but may require attention.
	LogLevelWarning LogLevel = "WARNING"
	// LogLevelError is used for messages that indicate an error occurred.
	LogLevelError LogLevel = "ERROR"
	// LogLevelFatal is used for messages that indicate a fatal error occurred. A logger implementation should
	// automatically exit the program, or trigger a crash, after logging a message with this level.
	LogLevelFatal LogLevel = "FATAL"
)

type ZerologMessage

type ZerologMessage interface {
	// ZeroLog shapes, and sends a customized message using zerolog event.
	ZeroLog(e *zerolog.Event)
}

ZerologMessage is a custom interface messages can use to customize the zerolog event.

If a message implements this interface, the logger will rely on the ZeroLog method to produce a message, rather than doing it itself.

The ZeroLog method is responsible for triggering the message with e.Msg or e.Msgf.

This method is only called for top-level messages. Nested messages will use the default serialization behavior.

func AsZeroLoggable

func AsZeroLoggable(data interface{}) (ZerologMessage, bool)

AsZeroLoggable checks if an interface implements the ZerologMessage interface. It returns the underlying implementation on success.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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