logger

package
v0.0.0-...-4814aa9 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2015 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package logger provides a custom logging abstract over the standard out logging of golang. All logging should by go to stdout according to 12-factor principles. Logging levels are based on RFC 5424: http://www.rfc-base.org/rfc-5424.html#

Index

Constants

View Source
const (
	//  RFC 5424 log levels.
	Emergency = iota
	Alert
	Critical
	Error
	Warning
	Notice
	Info
	Debug

	UseDefault = -1 // Note: literal consts must follow any iota decls else unexpected results.
)

Standard labels.

Variables

View Source
var (
	// Log labels.
	Labels = []string{"[EMERGENCY] ",
		"[ALERT] ",
		"[CRITICAL] ",
		"[ERROR] ",
		"[WARNING] ",
		"[NOTICE] ",
		"[INFO] ",
		"[DEBUG] ",
	}
)

Functions

This section is empty.

Types

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger provides a datastructure for all logging state.

func New

func New(lvl int, clrs bool) *Logger

New is a factory method to return a new logger instance.

func (*Logger) Alertf

func (l *Logger) Alertf(format string, v ...interface{})

Alertf prints an alert message to the system log.

func (*Logger) Criticalf

func (l *Logger) Criticalf(format string, v ...interface{})

Criticalf prints a critical message to the system log.

func (*Logger) Debugf

func (l *Logger) Debugf(format string, v ...interface{})

Debugf prints a debug message to the system log.

func (*Logger) Emergencyf

func (l *Logger) Emergencyf(format string, v ...interface{})

Emergencyf prints an emergency message to the system log, This is considered an unrecoverable error and the application also exits, unless dont exit = true.

func (*Logger) Errorf

func (l *Logger) Errorf(format string, v ...interface{})

Errorf prints an error message to the system log.

func (*Logger) GetLogLevel

func (l *Logger) GetLogLevel() int

GetLogLevel returns the current log level of the logger.

func (*Logger) Infof

func (l *Logger) Infof(format string, v ...interface{})

Infof prints an informational message to the system log.

func (*Logger) Noticef

func (l *Logger) Noticef(format string, v ...interface{})

Noticef prints a notice message to the system log.

func (*Logger) Output

func (l *Logger) Output(cd int, lbl string, format string, v ...interface{}) error

Output prints a message directly into the system log. Normally, you should use level message functions. so that level can trap the write.

func (*Logger) SetColouredLabels

func (l *Logger) SetColouredLabels()

SetColouredLabels sets the message labels to colourized text output.

func (*Logger) SetExitFunc

func (l *Logger) SetExitFunc(e exiter) error

SetExitFunc allows a user to set the exit function of the logger.

func (*Logger) SetLogLevel

func (l *Logger) SetLogLevel(lvl int) error

SetLogLevel allows a user to set the log level of the logger.

func (*Logger) SetPlainLabels

func (l *Logger) SetPlainLabels()

SetPlainLabels sets the message labels to simple text output.

func (*Logger) Warningf

func (l *Logger) Warningf(format string, v ...interface{})

Warningf prints a warning message to the system log.

Jump to

Keyboard shortcuts

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