log

package
v0.0.0-...-8705ae5 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultLevel = LevelInfo

DefaultLevel is the default log level.

View Source
const MaxLevel = LevelDebug

MaxLevel is the highest value allowed for a log level.

View Source
const MinLevel = LevelNone

MinLevel is the lowest value allowed for a log level.

Variables

View Source
var WriterErr = os.Stderr

WriterErr is the stream to use when writing error or warning logs.

View Source
var WriterInfo = os.Stdout

WriterInfo is the stream to use when writing info or error logs.

View Source
var WriterOut = os.Stdout

WriterOut is the stream to use when writing program output.

Functions

func Debug

func Debug(format string, toLog ...interface{})

Debug logs the formatted message as a debug message.

func Error

func Error(format string, toLog ...interface{})

Error logs the formatted message as an error.

func Fatal

func Fatal(format string, toLog ...interface{})

Fatal logs the formatted message as an error, and then exits.

func Info

func Info(format string, toLog ...interface{})

Info logs the formatted message as an informational message.

func Output

func Output(format string, toLog ...interface{})

Output logs the formatted message as output, without any prefixes or logging flags turned on.

func OutputStream

func OutputStream(reader io.Reader)

OutputStream writes all bytes from the given reader as output.

func Panic

func Panic(format string, toLog ...interface{})

Panic logs the formatted message as an error, and then panics.

func SetLevel

func SetLevel(level Level)

SetLevel sets the log level to the provided value.

func Verbose

func Verbose(format string, toLog ...interface{})

Verbose logs the formatted message as a verbose message.

func Warning

func Warning(format string, toLog ...interface{})

Warning logs the formatted message as a warning.

Types

type Level

type Level int

Level identifies the severity of a log line.

const (
	// LevelNone indicates that logs should not be sent to output.
	LevelNone Level = iota

	// LevelError indicates that error logs should be sent to output.
	LevelError

	// LevelWarning indicates that warning and error logs should be sent to output.
	LevelWarning

	// LevelInfo indicates that info, warning and error logs should be sent to output.
	LevelInfo

	// LevelVerbose indicates that verbose, info, warning and error logs should be sent to output.
	LevelVerbose

	// LevelDebug indicates that debug, verbose, info, warning and error logs should be sent to output.
	LevelDebug
)

Level enum

func GetLevel

func GetLevel() Level

GetLevel returns the currently selected log level.

func Parse

func Parse(logLevelString string) (Level, error)

Parse converts a string representation of a log level to a Level object.

func (Level) String

func (logLevel Level) String() (string, error)

String converts a log level into a string representation.

Jump to

Keyboard shortcuts

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