log

package
v1.1.0-alpha-4 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2017 License: Apache-2.0 Imports: 10 Imported by: 40

Documentation

Index

Constants

View Source
const (
	// DebugLevel level. Usually only enabled when debugging. Very verbose logging.
	DebugLevel = Level(log.LvlDebug)
	// InfoLevel level. General operational entries about what's going on inside the
	// application.
	InfoLevel = Level(log.LvlInfo)
	// ErrorLevel level. Logs. Used for errors that should definitely be noted.
	// Commonly used for hooks to send errors to an error tracking service.
	ErrorLevel = Level(log.LvlError)
	// FatalLevel level. Logs and then calls `os.Exit(1)`.
	FatalLevel = Level(log.LvlCrit)
)

Variables

This section is empty.

Functions

func Debug

func Debug(args ...interface{})

Debug logs a message at level Debug on the standard logger.

func Debugf

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

Debugf logs a message at level Debug on the standard logger.

func Error

func Error(args ...interface{})

Error logs a message at level Error on the standard logger.

func Errorf

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

Errorf logs a message at level Error on the standard logger.

func Fatal

func Fatal(args ...interface{})

Fatal logs a message at level Fatal on the standard logger.

func Fatalf

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

Fatalf logs a message at level Fatal on the standard logger.

func Info

func Info(args ...interface{})

Info logs a message at level Info on the standard logger.

func Infof

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

Infof logs a message at level Info on the standard logger.

func SetHandlers

func SetHandlers(handlers ...Handler)

SetHandlers allows you to set extra handlers on the std logger, besides the default StdErr Logger

func SetLevel

func SetLevel(level Level)

SetLevel defines at which level the std logger should log

Types

type Handler

type Handler interface {
	Log(r Record) error
}

Handler interface defines where and how log records are written. Handlers are composable, providing you great flexibility in combining them to achieve the logging structure that suits your applications.

func EmailHandler

func EmailHandler(minLevel Level, module string, to []string, from, smtp string, auth smtp.Auth) (Handler, error)

EmailHandler returns a handler which sends an email to the given email address in case a logged record is of the specified minimum level

func FileHandler

func FileHandler(path string) (Handler, error)

FileHandler returns a handler which writes log records to the give file using the given format. If the path already exists, FileHandler will append to the given file. If it does not, FileHandler will create the file with mode 0644.

func StderrHandler

func StderrHandler() Handler

StderrHandler is the default handler for all logs, unless handlers are given

func SyslogHandler

func SyslogHandler(tag string) (Handler, error)

SyslogHandler opens a connection to the system syslog daemon by calling syslog.New and writes all records to it.

type Level

type Level log.Lvl

Level type

func GetLevel

func GetLevel() Level

GetLevel returns the level used by the std logger

type Logger

type Logger interface {
	// verbose messages targeted at the developer
	Debug(args ...interface{})
	Debugf(format string, args ...interface{})
	// info messages targeted at the user and developer
	Info(args ...interface{})
	Infof(format string, args ...interface{})
	// error messages targeted at the user, sysadmin and developer,
	// but mostly at the sysadmin
	Error(args ...interface{})
	Errorf(format string, args ...interface{})
	// a fatal message targeted at the user and developer
	// the program will exit as this message
	// this level shouldn't be used by libraries
	Fatal(args ...interface{})
	Fatalf(format string, args ...interface{})
}

Logger defines a pragmatic Logger interface.

func New

func New(module string, level Level, handlers ...Handler) Logger

New logger, creates a new logger

func NopLogger

func NopLogger() Logger

NopLogger creates a Logger which discards all logs, and doesn't ever exit the process when a fatal error occurs.

type Record

type Record *log.Record

Record is what a Logger asks its handler to write

Jump to

Keyboard shortcuts

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