log

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2020 License: MIT Imports: 6 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

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

LogDebug works just as fmt.Printf, but prints into the Convenience loggers stream, as set with SetConvenienceLogger(). It uses the standard logger (package log) if te Convenience logger is unset. The message is only printed if ActiveLogLevel is set higher or equal to 'Debug'

func Error

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

LogError works just as fmt.Printf, but prints into the Convenience loggers stream, as set with SetConvenienceLogger(). It uses the standard logger (package log) if te Convenience logger is unset. The message is only printed if ActiveLogLevel is set higher or equal to 'Error'

func Fatal

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

Fatal works just as fmt.Printf, but prints into the Convenience loggers stream, as set with SetConvenienceLogger(). It uses the standard logger (package log) if te Convenience logger is unset. The message is only printed if ActiveLogLevel is set hogher or equal to 'Fatal'

func Info

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

LogInfo works just as fmt.Printf, but prints into the Convenience loggers stream, as set with SetConvenienceLogger(). It uses the standard logger (package log) if te Convenience logger is unset. The message is only printed if ActiveLogLevel is set higher or equal to 'Info'

func Warn

func Warn(format string, args ...interface{})

LogWarn works just as fmt.Printf, but prints into the Convenience loggers stream, as set with SetConvenienceLogger(). It uses the standard logger (package log) if te Convenience logger is unset. The message is only printed if ActiveLogLevel is set higher or equal to 'Warn'

Types

type LogLevel

type LogLevel int

LogLevel sets the criticality of a logging output. It is used to filter logging messages depending on their priority. Compare to log4j.

const (
	OFF LogLevel = iota
	FATAL
	ERROR
	WARN
	INFO
	DEBUG
	ALL
)

The predefined LogLevels that are used by the logging funktions below.

func LogLevelString

func LogLevelString(s string) (LogLevel, error)

LogLevelString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func LogLevelValues

func LogLevelValues() []LogLevel

LogLevelValues returns all values of the enum

func (LogLevel) IsALogLevel

func (i LogLevel) IsALogLevel() bool

IsALogLevel returns "true" if the value is listed in the enum definition. "false" otherwise

func (LogLevel) String

func (i LogLevel) String() string

type Logger

type Logger struct {
	ActiveLoglevel    LogLevel
	UseColouredOutput bool
	// contains filtered or unexported fields
}

A Logger is an onbject the offers several method to write Messages to a stream. Atually it is a wrapper aroung the 'log' package, that enhances the LogLevel functionality.

func NewLogger

func NewLogger(logfilename string, level LogLevel, useColouredLogging ...bool) *Logger

NewLogger creates a new Logger. It take a string file name as output file and a LogLevel to filter the messages that are wanted. The logger will use io.StdOut if the log filename string parameter is "STDERR"

func NewLoggerFromFile

func NewLoggerFromFile(logfile io.Writer, level LogLevel, useColouredOutput bool) *Logger

NewLoggerFromFile creates a new Logger. It take a file parameter (io.Writer) output file and a LogLevel to filter the messages that are wanted. The first created logger wil be set to be the convenience logger (see the convenience functions Log...() below). Afterwards created loggers will not overwrie this. The convenience logger can be reset by using the method SetConvenienceLogger.

func (*Logger) Debug

func (l *Logger) Debug(format string, args ...interface{})

Debug works just as fmt.Printf, but prints into the loggers stream. The message is only printed if ActiveLogLevel is set higher or equal to 'Debug'

func (*Logger) Error

func (l *Logger) Error(format string, args ...interface{})

Error works just as fmt.Printf, but prints into the loggers stream. The message is only printed if ActiveLogLevel is set higher or equal to 'Error'

func (*Logger) Fatal

func (l *Logger) Fatal(format string, args ...interface{})

Fatal works just as fmt.Printf, but prints into the loggers stream. The message is only printed if ActiveLogLevel is set hogher or equal to 'Fatal'

func (*Logger) Info

func (l *Logger) Info(format string, args ...interface{})

Info works just as fmt.Printf, but prints into the loggers stream. The message is only printed if ActiveLogLevel is set higher or equal to 'Info'

func (*Logger) SetConvenienceLogger

func (l *Logger) SetConvenienceLogger()

SetConvenienceLogger sets a logger as a singleton object. The LogInfo etc. functions use this singleton to offer logging function without an object context.

func (*Logger) Warn

func (l *Logger) Warn(format string, args ...interface{})

Warn works just as fmt.Printf, but prints into the loggers stream. The message is only printed if ActiveLogLevel is set higher or equal to 'Warn'

Jump to

Keyboard shortcuts

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