logger

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NoCode means the entry code hasn't been set
	NoCode = iota
	// CloneError means we were unable to successfully clone the resource
	CloneError
	// ScanError means there was some issue scanning the cloned resource
	ScanError
	// ResourceCleanupError means we couldn't remove the resources that were cloned after a scan
	ResourceCleanupError
	// CommandError means there was an error with an external command
	CommandError
	// CloneDetail are log entries that are informational
	CloneDetail
	// ScanDetail are log entries that are informational
	ScanDetail
)

Variables

This section is empty.

Functions

func Fatal

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

Fatal emits an CRITICAL level log and stops the program

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

Types

type Entry

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

Entry defines a log entry

func Critical added in v0.0.13

func Critical(msg string, a ...any) *Entry

Critical emits an CRITICAL level log

func Debug

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

Debug emits an DEBUG level log

func Error

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

Error emits an ERROR level log

func Info

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

Info emits an INFO level log

func Warning

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

Warning emits an WARNING level log

func (Entry) String

func (e Entry) String() string

String renders a log entry structure to the JSON format

type LogCode added in v0.0.13

type LogCode int

LogCode defines the set of codes that can be set on an Entry

func (LogCode) String added in v0.0.13

func (code LogCode) String() string

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