log

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2020 License: GPL-3.0 Imports: 11 Imported by: 24

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Critical

func Critical(msg string)

Critical is used to log events that completely break the system. Operation connot continue. User/Admin must be informed.

func Criticalf

func Criticalf(format string, things ...interface{})

Criticalf is used to log events that completely break the system. Operation connot continue. User/Admin must be informed.

func Debug

func Debug(msg string)

Debug is used to log minor errors or unexpected events. These occurrences are usually not worth mentioning in itself, but they might hint at a bigger problem.

func Debugf

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

Debugf is used to log minor errors or unexpected events. These occurrences are usually not worth mentioning in itself, but they might hint at a bigger problem.

func EnableScheduling added in v0.3.0

func EnableScheduling()

EnableScheduling enables external scheduling of the logger. This will require to manually trigger writes via TriggerWrite whenevery logs should be written. Please note that full buffers will also trigger writing. Must be called before Start() to have an effect.

func Error

func Error(msg string)

Error is used to log errors that break or impair functionality. The task/process may have to be aborted and tried again later. The system is still operational. Maybe User/Admin should be informed.

func Errorf

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

Errorf is used to log errors that break or impair functionality. The task/process may have to be aborted and tried again later. The system is still operational.

func Info

func Info(msg string)

Info is used to log mildly significant events. Should be used to inform about somewhat bigger or user affecting events that happen.

func Infof

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

Infof is used to log mildly significant events. Should be used to inform about somewhat bigger or user affecting events that happen.

func SetLogLevel

func SetLogLevel(level Severity)

SetLogLevel sets a new log level. Only effective after Start().

func SetPkgLevels added in v0.3.0

func SetPkgLevels(levels map[string]Severity)

SetPkgLevels sets individual log levels for packages. Only effective after Start().

func Shutdown

func Shutdown()

Shutdown writes remaining log lines and then stops the log system.

func Start

func Start() (err error)

Start starts the logging system. Must be called in order to see logs.

func Trace

func Trace(msg string)

Trace is used to log tiny steps. Log traces to context if you can!

func Tracef

func Tracef(format string, things ...interface{})

Tracef is used to log tiny steps. Log traces to context if you can!

func TriggerWriter added in v0.3.0

func TriggerWriter()

TriggerWriter triggers log output writing.

func TriggerWriterChannel added in v0.3.0

func TriggerWriterChannel() chan struct{}

TriggerWriterChannel returns the channel to trigger log writing. Returned channel will close if EnableScheduling() is not called correctly.

func UnSetPkgLevels added in v0.3.0

func UnSetPkgLevels()

UnSetPkgLevels removes all individual log levels for packages.

func Warning

func Warning(msg string)

Warning is used to log (potentially) bad events, but nothing broke (even a little) and there is no need to panic yet.

func Warningf

func Warningf(format string, things ...interface{})

Warningf is used to log (potentially) bad events, but nothing broke (even a little) and there is no need to panic yet.

Types

type ContextTracer

type ContextTracer struct {
	sync.Mutex
	// contains filtered or unexported fields
}

ContextTracer is attached to a context in order bind logs to a context.

func AddTracer

func AddTracer(ctx context.Context) (context.Context, *ContextTracer)

AddTracer adds a ContextTracer to the returned Context. Will return a nil ContextTracer if logging level is not set to trace. Will return a nil ContextTracer if one already exists. Will return a nil ContextTracer in case of an error. Will return a nil context if nil.

func Tracer

func Tracer(ctx context.Context) *ContextTracer

Tracer returns the ContextTracer previously added to the given Context.

func (*ContextTracer) Critical added in v0.3.0

func (tracer *ContextTracer) Critical(msg string)

Critical is used to log events that completely break the system. Operation connot continue. User/Admin must be informed.

func (*ContextTracer) Criticalf added in v0.3.0

func (tracer *ContextTracer) Criticalf(format string, things ...interface{})

Criticalf is used to log events that completely break the system. Operation connot continue. User/Admin must be informed.

func (*ContextTracer) Debug added in v0.3.0

func (tracer *ContextTracer) Debug(msg string)

Debug is used to log minor errors or unexpected events. These occurrences are usually not worth mentioning in itself, but they might hint at a bigger problem.

func (*ContextTracer) Debugf added in v0.3.0

func (tracer *ContextTracer) Debugf(format string, things ...interface{})

Debugf is used to log minor errors or unexpected events. These occurrences are usually not worth mentioning in itself, but they might hint at a bigger problem.

func (*ContextTracer) Error

func (tracer *ContextTracer) Error(msg string)

Error is used to log errors that break or impair functionality. The task/process may have to be aborted and tried again later. The system is still operational. Maybe User/Admin should be informed.

func (*ContextTracer) Errorf

func (tracer *ContextTracer) Errorf(format string, things ...interface{})

Errorf is used to log errors that break or impair functionality. The task/process may have to be aborted and tried again later. The system is still operational.

func (*ContextTracer) Info added in v0.3.0

func (tracer *ContextTracer) Info(msg string)

Info is used to log mildly significant events. Should be used to inform about somewhat bigger or user affecting events that happen.

func (*ContextTracer) Infof added in v0.3.0

func (tracer *ContextTracer) Infof(format string, things ...interface{})

Infof is used to log mildly significant events. Should be used to inform about somewhat bigger or user affecting events that happen.

func (*ContextTracer) Submit added in v0.3.0

func (tracer *ContextTracer) Submit()

Submit collected logs on the context for further processing/outputting. Does nothing if called on a nil ContextTracer.

func (*ContextTracer) Trace

func (tracer *ContextTracer) Trace(msg string)

Trace is used to log tiny steps. Log traces to context if you can!

func (*ContextTracer) Tracef

func (tracer *ContextTracer) Tracef(format string, things ...interface{})

Tracef is used to log tiny steps. Log traces to context if you can!

func (*ContextTracer) Warning

func (tracer *ContextTracer) Warning(msg string)

Warning is used to log (potentially) bad events, but nothing broke (even a little) and there is no need to panic yet.

func (*ContextTracer) Warningf

func (tracer *ContextTracer) Warningf(format string, things ...interface{})

Warningf is used to log (potentially) bad events, but nothing broke (even a little) and there is no need to panic yet.

type ContextTracerKey

type ContextTracerKey struct{}

ContextTracerKey is the key used for the context key/value storage.

type Severity added in v0.3.0

type Severity uint32

Severity describes a log level.

const (
	TraceLevel    Severity = 1
	DebugLevel    Severity = 2
	InfoLevel     Severity = 3
	WarningLevel  Severity = 4
	ErrorLevel    Severity = 5
	CriticalLevel Severity = 6
)

Log Levels

func ParseLevel

func ParseLevel(level string) Severity

ParseLevel returns the level severity of a log level name.

func (Severity) String added in v0.3.0

func (s Severity) String() string

Jump to

Keyboard shortcuts

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