logger

package
v0.0.0-...-b593ba2 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 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 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 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 StreamOutput

func StreamOutput(pipe io.Reader, logFunction func(...interface{}), wg *sync.WaitGroup, outputChan chan string)

StreamOutput calls the provided logFunction on every line from the provided pipe outputChan will contain the N most recent lines of output, based on the length of the channel

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