logger

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(msg string, a ...any)

Debug emits an DEBUG level log

func Error

func Error(msg string, a ...any)

Error emits an ERROR level log

func Fatal

func Fatal(msg string, a ...any)

Fatal emits an CRITICAL level log and stops the program

func Info

func Info(msg string, a ...any)

Info emits an INFO level log

func SetLoggerFormat

func SetLoggerFormat(logFormat LogFormat) error

SetLoggerFormat adjusts the format Entry uses when calling String() on it

func SetLoggerLevel

func SetLoggerLevel(levelName string) error

SetLoggerLevel takes the string version of the name and sets the current level

func Warning

func Warning(msg string, a ...any)

Warning emits an WARNING level log

Types

type Entry

type Entry struct {
	Time     string `json:"time"`
	Severity string `json:"severity"`
	Message  string `json:"message"`
}

Entry defines a log entry

func (Entry) String

func (e Entry) String() string

String renders a log entry structure to the JSON format

type LogFormat

type LogFormat int

LogFormat is used to set the how the log messages should be displayed

const (
	// JSON displays the logs as JSON dicts
	JSON LogFormat = 0
	// HUMAN displays the logs in a way that's nice for humans to read
	HUMAN LogFormat = 1
)

type LogLevel

type LogLevel int

LogLevel is used to determine which log severities should actually log

const (
	// NOTSET will log everything
	NOTSET LogLevel = 0
	// DEBUG will enable these logs and higher
	DEBUG LogLevel = 10
	// INFO will enable these logs and higher
	INFO LogLevel = 20
	// WARNING will enable these logs and higher
	WARNING LogLevel = 30
	// ERROR will enable these logs and higher
	ERROR LogLevel = 40
	// CRITICAL will enable these logs and higher
	CRITICAL LogLevel = 50
)

func GetLoggerLevel

func GetLoggerLevel() LogLevel

GetLoggerLevel returns the current logger level

func (LogLevel) String

func (l LogLevel) String() string

String renders a LogLevel as its string value

Jump to

Keyboard shortcuts

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