Documentation ¶
Overview ¶
Package dlog provides logging functions with caller file and line information, logging levels and level and text filters.
Index ¶
- Variables
- func ErrorCheck(in error) error
- func SetLogger(l Logger)
- type FullLogger
- type Level
- type Logger
- type RegexLogger
- func (l *RegexLogger) CreateLogFile()
- func (l *RegexLogger) Error(in ...interface{})
- func (l *RegexLogger) FileWrite(in ...interface{})
- func (l *RegexLogger) GetLogLevel() Level
- func (l *RegexLogger) Info(in ...interface{})
- func (l *RegexLogger) SetDebugFilter(filter string)
- func (l *RegexLogger) SetDebugLevel(dL Level)
- func (l *RegexLogger) SetWriter(w io.Writer) error
- func (l *RegexLogger) Verb(in ...interface{})
- func (l *RegexLogger) Warn(in ...interface{})
Constants ¶
This section is empty.
Variables ¶
var CreateLogFile = func() {}
CreateLogFile creates a file for logs to be written to by log functions. This is a NOP if fullOakLogger is not set by SetLogger.
var Error = func(...interface{}) {}
Error will write a log if the debug level is not NONE
var FileWrite = func(...interface{}) {}
FileWrite logs by writing to file (if possible) but does not log to console as well. This is a NOP if fullOakLogger is not set by SetLogger.
var GetLogLevel = func() Level { return NONE }
GetLogLevel returns the log level of the fullOakLogger, or NONE if there is not fullOakLogger.
var Info = func(...interface{}) {}
Info will write a log if the debug level is higher than WARN
var SetDebugFilter = func(string) {}
SetDebugFilter defines a string that all logs should be checked against-- if the log message does not contain the input string the log will not log. This is a NOP if fullOakLogger is not set by SetLogger.
var SetDebugLevel = func(Level) {}
SetDebugLevel sets the log level of the fullOakLogger. This is a NOP if fullOakLogger is not set by SetLogger.
var Verb = func(...interface{}) {}
Verb will write a log if the debug level is higher than INFO
var Warn = func(...interface{}) {}
Warn will write a log if the debug level is higher than ERROR
Functions ¶
func ErrorCheck ¶
ErrorCheck checks that the input is not nil, then calls Error on it if it is not. Otherwise it does nothing. Emits the input error as is for additional processing if desired.
Types ¶
type FullLogger ¶
type FullLogger interface { Logger GetLogLevel() Level FileWrite(in ...interface{}) SetDebugFilter(filter string) SetDebugLevel(dL Level) CreateLogFile() }
A FullLogger supports, in addition to Logger's functions, the ability to set and get a log level, and create and write logs directly to file.
type Level ¶
type Level int
Level represents the levels a debug message can have
func ParseDebugLevel ¶
ParseDebugLevel parses the input string as a known debug levels
type Logger ¶
type Logger interface { Error(...interface{}) Warn(...interface{}) Info(...interface{}) Verb(...interface{}) }
A Logger is a minimal log interface for the content oak wants to log: four levels of logging.
type RegexLogger ¶ added in v2.4.0
type RegexLogger struct { // FilterOverrideLevel is the log level at which // logs will be shown regardless of the filter. FilterOverrideLevel Level // contains filtered or unexported fields }
RegexLogger is a logger implementation that offers some additional features on top of the default logger. Todo v3: combine logger implementations.
func NewRegexLogger ¶ added in v2.4.0
func NewRegexLogger(level Level) *RegexLogger
NewRegexLogger returns a custom logger that writes to os.Stdout and overrides filters on WARN or higher messages.
func (*RegexLogger) CreateLogFile ¶ added in v2.4.0
func (l *RegexLogger) CreateLogFile()
CreateLogFile creates a file in the 'logs' directory of the starting point of this program to write logs to
func (*RegexLogger) Error ¶ added in v2.4.0
func (l *RegexLogger) Error(in ...interface{})
Error will write a dlog if the debug level is not NONE
func (*RegexLogger) FileWrite ¶ added in v2.4.0
func (l *RegexLogger) FileWrite(in ...interface{})
FileWrite acts just like a regular write on a RegexLogger. It does not respect overrides.
func (*RegexLogger) GetLogLevel ¶ added in v2.4.0
func (l *RegexLogger) GetLogLevel() Level
GetLogLevel returns the current log level, i.e WARN or INFO...
func (*RegexLogger) Info ¶ added in v2.4.0
func (l *RegexLogger) Info(in ...interface{})
Info will write a dLog if the debug level is higher than WARN
func (*RegexLogger) SetDebugFilter ¶ added in v2.4.0
func (l *RegexLogger) SetDebugFilter(filter string)
SetDebugFilter sets the string which determines what debug messages get printed. Only messages which contain the filer as a pseudo-regex
func (*RegexLogger) SetDebugLevel ¶ added in v2.4.0
func (l *RegexLogger) SetDebugLevel(dL Level)
SetDebugLevel sets what message levels of debug will be printed.
func (*RegexLogger) SetWriter ¶ added in v2.4.0
func (l *RegexLogger) SetWriter(w io.Writer) error
SetWriter sets the writer that RegexLogger logs to
func (*RegexLogger) Verb ¶ added in v2.4.0
func (l *RegexLogger) Verb(in ...interface{})
Verb will write a dLog if the debug level is higher than INFO
func (*RegexLogger) Warn ¶ added in v2.4.0
func (l *RegexLogger) Warn(in ...interface{})
Warn will write a dLog if the debug level is higher than ERROR