log

package
v3.3.12 Latest Latest
Warning

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

Go to latest
Published: May 13, 2020 License: BSD-2-Clause Imports: 10 Imported by: 13

Documentation

Index

Constants

View Source
const (
	DEFAULT_DEPTH = 3
)

Variables

View Source
var (
	ErrNotOpen      = errors.New("Logger is not open")
	ErrInvalidLevel = errors.New("Log level is invalid")
)

Functions

This section is empty.

Types

type Level

type Level int
const (
	OFF      Level = 0
	DEBUG    Level = 1
	INFO     Level = 2
	WARN     Level = 3
	ERROR    Level = 4
	CRITICAL Level = 5
)

func LevelFromString

func LevelFromString(s string) (l Level, err error)

func (Level) String

func (l Level) String() string

func (Level) Valid

func (l Level) Valid() bool

type Logger

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

func New

func New(wtr io.WriteCloser) *Logger

New creates a new logger with the given writer at log level INFO

func NewDiscardLogger

func NewDiscardLogger() *Logger

func NewFile

func NewFile(f string) (*Logger, error)

NewFile creates a new logger with the first writer being a file The file is created if it does not exist, and is opened in append mode it is safe to use NewFile on existing logs

func NewStderrLogger added in v3.3.4

func NewStderrLogger(fileOverride string) (*Logger, error)

func NewStderrLoggerEx added in v3.3.4

func NewStderrLoggerEx(fileOverride string, cb StderrCallback) (*Logger, error)

func (*Logger) AddWriter

func (l *Logger) AddWriter(wtr io.WriteCloser) error

Add a new writer which will get all the log lines as they are handled

func (*Logger) Close

func (l *Logger) Close() (err error)

Close closes the logger and all currently associated writers writers that have been deleted are NOT closed

func (*Logger) Critical

func (l *Logger) Critical(f string, args ...interface{}) error

Critical writes a CRITICALinfo level log to the underlying writer, if the logging level is higher than DEBUG no action is taken

func (*Logger) CriticalWithDepth added in v3.3.12

func (l *Logger) CriticalWithDepth(d int, f string, args ...interface{}) error

Critical writes a CRITICALinfo level log to the underlying writer, if the logging level is higher than DEBUG no action is taken

func (*Logger) Debug

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

Debug writes a DEBUG level log to the underlying writer, if the logging level is higher than DEBUG no action is taken

func (*Logger) DebugWithDepth added in v3.3.12

func (l *Logger) DebugWithDepth(d int, f string, args ...interface{}) error

Debug writes a DEBUG level log to the underlying writer, if the logging level is higher than DEBUG no action is taken

func (*Logger) DeleteWriter

func (l *Logger) DeleteWriter(wtr io.Writer) error

DeleteWriter removes a writer from the logger, it will not be closed on logging Close

func (*Logger) Error

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

Error writes an ERROR level log to the underlying writer, if the logging level is higher than DEBUG no action is taken

func (*Logger) ErrorWithDepth added in v3.3.12

func (l *Logger) ErrorWithDepth(d int, f string, args ...interface{}) error

Error writes an ERROR level log to the underlying writer, if the logging level is higher than DEBUG no action is taken

func (*Logger) Fatal

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

Fatal writes a log, closes the logger, and issues an os.Exit(-1)

func (*Logger) FatalCode

func (l *Logger) FatalCode(code int, f string, args ...interface{})

FatalCode is identical to a log.Fatal, except it allows for controlling the exit code

func (*Logger) GetLevel

func (l *Logger) GetLevel() Level

GetLevel returns the current logging level

func (*Logger) Info

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

Info writes an INFO level log to the underlying writer, if the logging level is higher than DEBUG no action is taken

func (*Logger) InfoWithDepth added in v3.3.12

func (l *Logger) InfoWithDepth(d int, f string, args ...interface{}) error

Info writes an INFO level log to the underlying writer, if the logging level is higher than DEBUG no action is taken

func (*Logger) SetLevel

func (l *Logger) SetLevel(lvl Level) error

SetLevel sets the log level, Off disables logging and any logging call that is less than the level current level are not logged

func (*Logger) SetLevelString

func (l *Logger) SetLevelString(s string) error

SetLevelString sets the log level using a string, this is a helper function so that you can just hand the config file value directly in

func (*Logger) Warn

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

Warn writes an WARN level log to the underlying writer, if the logging level is higher than DEBUG no action is taken

func (*Logger) WarnWithDepth added in v3.3.12

func (l *Logger) WarnWithDepth(d int, f string, args ...interface{}) error

Warn writes an WARN level log to the underlying writer, if the logging level is higher than DEBUG no action is taken

func (*Logger) Write added in v3.3.10

func (l *Logger) Write(b []byte) (n int, err error)

implement writer interface so it can be handed to a standard loger

type StderrCallback added in v3.3.4

type StderrCallback func(io.Writer)

Jump to

Keyboard shortcuts

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