logging

package
v0.0.0-...-98f36a1 Latest Latest
Warning

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

Go to latest
Published: May 25, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Level

type Level uint8

Level is the log level

const (
	FatalLevel Level = iota
	ErrorLevel
	WarningLevel
	InfoLevel
	DebugLevel
)

Log levels

func (Level) String

func (level Level) String() string

String returns the string representation of the levels (used when logging)

type Logger

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

Logger is a leveled logger capable of optionally logging to syslog

func NewLogger

func NewLogger() *Logger

NewLogger returns a new logger with levels

func (*Logger) Close

func (l *Logger) Close() error

Close closes any open connections the logger has

func (*Logger) Debugf

func (l *Logger) Debugf(m string, args ...interface{})

Debugf logs a debug message

func (*Logger) DisableSyslog

func (l *Logger) DisableSyslog() error

DisableSyslog always disables writing to syslog, but returns an errors from closing the connection

func (*Logger) EnableSyslog

func (l *Logger) EnableSyslog(facility syslog.Priority) (err error)

EnableSyslog enables sending of log messages to syslog

It returns any errors occurring while opening the connection (it does not enable syslog logging if there are errors)

func (*Logger) Errorf

func (l *Logger) Errorf(m string, args ...interface{})

Errorf logs an error message

func (*Logger) Fatalf

func (l *Logger) Fatalf(m string, args ...interface{})

Fatalf logs a fatal message and exits

func (*Logger) Infof

func (l *Logger) Infof(m string, args ...interface{})

Infof logs an info message

func (*Logger) Logf

func (l *Logger) Logf(level Level, m string, args ...interface{})

Logf logs a message with the given level

func (*Logger) Warningf

func (l *Logger) Warningf(m string, args ...interface{})

Warningf logs a warning message

func (*Logger) Writer

func (l *Logger) Writer(level Level) io.WriteCloser

Writer returns a io.Writer that results in leveled log output using the given level

Caller is expected to close the writer

Jump to

Keyboard shortcuts

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