Documentation ¶
Index ¶
- Variables
- func Critical(msg string)
- func Criticalf(format string, things ...interface{})
- func Debug(msg string)
- func Debugf(format string, things ...interface{})
- func EnableScheduling()
- func Error(msg string)
- func Errorf(format string, things ...interface{})
- func GetLastUnexpectedLogs() []string
- func Info(msg string)
- func Infof(format string, things ...interface{})
- func SetAdapter(a Adapter)
- func SetLogLevel(level Severity)
- func SetPkgLevels(levels map[string]Severity)
- func Shutdown()
- func Start() (err error)
- func TotalCriticalLogLines() uint64
- func TotalErrorLogLines() uint64
- func TotalWarningLogLines() uint64
- func Trace(msg string)
- func Tracef(format string, things ...interface{})
- func TriggerWriter()
- func TriggerWriterChannel() chan struct{}
- func UnSetPkgLevels()
- func Warning(msg string)
- func Warningf(format string, things ...interface{})
- type Adapter
- type AdapterFunc
- type ContextTracer
- func (tracer *ContextTracer) Critical(msg string)
- func (tracer *ContextTracer) Criticalf(format string, things ...interface{})
- func (tracer *ContextTracer) Debug(msg string)
- func (tracer *ContextTracer) Debugf(format string, things ...interface{})
- func (tracer *ContextTracer) Error(msg string)
- func (tracer *ContextTracer) Errorf(format string, things ...interface{})
- func (tracer *ContextTracer) Info(msg string)
- func (tracer *ContextTracer) Infof(format string, things ...interface{})
- func (tracer *ContextTracer) Submit()
- func (tracer *ContextTracer) Trace(msg string)
- func (tracer *ContextTracer) Tracef(format string, things ...interface{})
- func (tracer *ContextTracer) Warning(msg string)
- func (tracer *ContextTracer) Warningf(format string, things ...interface{})
- type ContextTracerKey
- type FormatFunc
- type Message
- type Severity
- type SimpleFileAdapter
Constants ¶
This section is empty.
Variables ¶
var ( // StdoutAdapter is a simple file adapter that writes // all logs to os.Stdout using a predefined format. StdoutAdapter = &SimpleFileAdapter{ File: os.Stdout, Format: defaultColorFormater, } // StderrAdapter is a simple file adapter that writes // all logs to os.Stdout using a predefined format. StderrAdapter = &SimpleFileAdapter{ File: os.Stderr, Format: defaultColorFormater, } )
Functions ¶
func Critical ¶
func Critical(msg string)
Critical is used to log events that completely break the system. Operation cannot 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 cannot 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 ¶
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 GetLastUnexpectedLogs ¶
func GetLastUnexpectedLogs() []string
GetLastUnexpectedLogs returns the last 10 log lines of level Warning an up.
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 SetAdapter ¶
func SetAdapter(a Adapter)
SetAdapter configures the logging adapter to use. This must be called before the log package is initialized.
func SetLogLevel ¶
func SetLogLevel(level Severity)
SetLogLevel sets a new log level. Only effective after Start().
func SetPkgLevels ¶
SetPkgLevels sets individual log levels for packages. Only effective after Start().
func Start ¶
func Start() (err error)
Start starts the logging system. Must be called in order to see logs.
func TotalCriticalLogLines ¶
func TotalCriticalLogLines() uint64
TotalCriticalLogLines returns the total amount of critical log lines since start of the program.
func TotalErrorLogLines ¶
func TotalErrorLogLines() uint64
TotalErrorLogLines returns the total amount of error log lines since start of the program.
func TotalWarningLogLines ¶
func TotalWarningLogLines() uint64
TotalWarningLogLines returns the total amount of warning log lines since start of the program.
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 TriggerWriterChannel ¶
func TriggerWriterChannel() chan struct{}
TriggerWriterChannel returns the channel to trigger log writing. Returned channel will close if EnableScheduling() is not called correctly.
func UnSetPkgLevels ¶
func UnSetPkgLevels()
UnSetPkgLevels removes all individual log levels for packages.
Types ¶
type Adapter ¶
type Adapter interface { // Write is called for each log message. Write(msg Message, duplicates uint64) }
Adapter is used to write logs.
type AdapterFunc ¶
AdapterFunc is a convenience type for implementing Adapter.
func (AdapterFunc) Write ¶
func (fn AdapterFunc) Write(msg Message, duplicates uint64)
Write implements Adapter and calls fn.
type ContextTracer ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 FormatFunc ¶
FormatFunc formats msg into a string.
type Message ¶
type Message interface { Text() string Severity() Severity Time() time.Time File() string LineNumber() int }
Message describes a log level message and is implemented by logLine.
type Severity ¶
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 ¶
ParseLevel returns the level severity of a log level name.
type SimpleFileAdapter ¶
type SimpleFileAdapter struct { Format FormatFunc File *os.File }
SimpleFileAdapter implements Adapter and writes all messages to File.
func (*SimpleFileAdapter) Write ¶
func (fileAdapter *SimpleFileAdapter) Write(msg Message, duplicates uint64)
Write implements Adapter and writes msg the underlying file.