log

package module
v0.0.0-...-552e9b1 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2021 License: MIT Imports: 5 Imported by: 5

Documentation

Index

Constants

View Source
const (
	// LevelTrace is used for printing verbose network communications
	LevelTrace = 5

	// LevelDebug is used for printing the results of actions which are
	// essential to the succeeding of the program, but not important enough to
	// show up in the logs of every server which runs this program
	LevelDebug = 4

	// LevelInfo is used for printing messages which are useful to for knowing
	// the current state of the application. These messages should not show up
	// too often, and they should be useful for system administrators to see
	LevelInfo = 3

	// LevelWarning is used for notifying the administrator that something is
	// wrong, but the application can still function properly
	LevelWarning = 2

	// LevelError is used to indicate that something important broke and the
	// application is now in an inconsistent state. The problem should be fixed
	// before restarting the application
	LevelError = 1

	// LevelNone makes the application log no messages at all
	LevelNone = 0
)

Log level, higher number is more verbosity

Variables

View Source
var Colours = false

Colours controls if the log package should print ANSI colour codes depending on the log level of the logged message. Defaults to false

View Source
var Logger = log.New(writer(0), "", 0)

Logger is an instance of the standard Go log.Logger which can be used by Go packages to log to the Default log level

Functions

func Debug

func Debug(msgFmt string, v ...interface{})

Debug logs a debugging message

func Error

func Error(msgFmt string, v ...interface{})

Error logs an error message, and prints an execution stack afterwards

func Info

func Info(msgFmt string, v ...interface{})

Info logs an informative message

func SetDefaultLevel

func SetDefaultLevel(level int)

SetDefaultLevel set the log level for the log messages written to the Write function. This is useful for integrating packages which use Go's native logger interface into this log package.

An example of this is the very verbose http logger which tends to spam logs with messages which can otherwise not be silenced.

func SetLogLevel

func SetLogLevel(level int)

SetLogLevel set the logging verbosity. 0 is lowest (log nothing at all), 5 is highest (log all debug and trace messages)

func Trace

func Trace(msgFmt string, v ...interface{})

Trace logs a tracing message

func Warn

func Warn(msgFmt string, v ...interface{})

Warn logs a warning message

Types

This section is empty.

Jump to

Keyboard shortcuts

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