logger

package
v0.0.0-...-fc5b1e8 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LevelsPlaceholder are all valid log levels separated by '|' character.
	LevelsPlaceholder = "(panic|fatal|error|warn|info|debug|trace)"

	// LevelsFlag is the suggested name of the flag for loglevel
	LevelsFlag = "log-level"

	// LevelsHelp is the suggested help message for the loglevel flag
	LevelsHelp = "The minimum log level."

	// FileFlag is the suggested name for logfile flag
	FileFlag = "log-file"

	// FileFlagHelp is the suggested help message for the logfile flag
	FileFlagHelp = "Path to the image's log file."

	// ColorsPlaceholder are all valid log colors separated by '|' character.
	ColorsPlaceholder = "(always|auto|never)"

	// ColorFlag is the suggested name for logcolor flag
	ColorFlag = "log-color"

	// ColorFlagHelp is the suggested help message for the logcolor flag
	ColorFlagHelp = "Color setting for log terminal output."
)

Variables

View Source
var (
	// Log contains the shared Logger
	Log *logrus.Logger
)

Functions

func Colors

func Colors() []string

Colors returns list of strings representing valid log colors.

func FatalOnError

func FatalOnError(err interface{}, args ...interface{})

FatalOnError logs a fatal error and any message strings, then exists (while running any cleanup functions registered with the log package)

func FormatMessageBox

func FormatMessageBox(message []string) []string

FormatMessageBox formats a message into a box with a border. The box is automatically sized to fit the longest line. Each line will be centered in the box.

func InitBestEffort

func InitBestEffort(lf *LogFlags)

InitBestEffort runs InitStderrLog always, and InitLogFile if path is not empty

func InitStderrLog

func InitStderrLog()

InitStderrLog initializes the logger to print to stderr

func Levels

func Levels() []string

Levels returns list of strings representing valid log levels.

func PanicOnError

func PanicOnError(err interface{}, args ...interface{})

PanicOnError logs the error and any message strings and then panics

func PrintMessageBox

func PrintMessageBox(level logrus.Level, message []string)

PrintMessageBox prints a message box to the log with the specified log level.

func ReplaceStderrFormatter

func ReplaceStderrFormatter(newFormatter logrus.Formatter) (oldFormatter logrus.Formatter)

ReplaceStderrFormatter replaces the stderr formatter and returns the old formatter

func ReplaceStderrWriter

func ReplaceStderrWriter(newOut io.Writer) (oldOut io.Writer)

ReplaceStderrWriter replaces the stderr writer and returns the old one

func SetFileLogLevel

func SetFileLogLevel(level string) (err error)

SetFileLogLevel sets the lowest log level for file output

func SetStderrLogLevel

func SetStderrLogLevel(level string) (err error)

SetStderrLogLevel sets the lowest log level for stderr output

func WarningOnError

func WarningOnError(err interface{}, args ...interface{})

WarningOnError logs a warning error and any message strings

Types

type LogFlags

type LogFlags struct {
	LogColor *string
	LogFile  *string
	LogLevel *string
}

Jump to

Keyboard shortcuts

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