Documentation
¶
Index ¶
- func SPrintCaller(skip int) string
- func SPrintStack(skip, max int) string
- func SetCustomWriters(writers ...Writer)
- type ColorTheme
- type ConsoleWriter
- type DiskWriter
- type DiskWriterConfig
- type Level
- type Logger
- func (l *Logger) CheckErr(f func() error)
- func (l *Logger) Critical(message string, args ...interface{})
- func (l *Logger) Debug(message string, args ...interface{})
- func (l *Logger) Error(message string, args ...interface{}) error
- func (l *Logger) Info(message string, args ...interface{})
- func (l *Logger) IsDebugEnabled() bool
- func (l *Logger) IsError(err error) bool
- func (l *Logger) JSONify(v interface{}) string
- func (l *Logger) JSONifyIndent(v interface{}) string
- func (l *Logger) Log(level Level, message string, args ...interface{})
- func (l *Logger) LogLevel() Level
- func (l *Logger) PrintCaller(skip int)
- func (l *Logger) PrintStackTrace()
- func (l *Logger) Recover(v interface{}) error
- func (l *Logger) SetLogLevel(level Level)
- func (l *Logger) Trace(message string, args ...interface{})
- func (l *Logger) Warn(message string, args ...interface{})
- type SyslogWriter
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SPrintCaller ¶
SPrintCaller returns a string with information about caller
func SPrintStack ¶
SPrintStack will print the current stack to a returned string
Types ¶
type ConsoleWriter ¶
type ConsoleWriter struct { }
ConsoleWriter will write out to a console
func (*ConsoleWriter) BuildTheme ¶
func (w *ConsoleWriter) BuildTheme(module string) ColorTheme
BuildTheme ...
func (*ConsoleWriter) Log ¶
func (w *ConsoleWriter) Log(level Level, theme ColorTheme, module, filename string, line int, timestamp time.Time, message string)
Log ...
type DiskWriter ¶
type DiskWriter struct { DiskWriterConfig // contains filtered or unexported fields }
DiskWriter ...
func NewDiskWriter ¶
func NewDiskWriter(logpath string, config DiskWriterConfig) *DiskWriter
NewDiskWriter ...
func (*DiskWriter) Log ¶
func (w *DiskWriter) Log(level Level, _ ColorTheme, module, filename string, line int, timestamp time.Time, message string)
Log ...
type DiskWriterConfig ¶
type DiskWriterConfig struct { RotateDuration time.Duration // rotates after time.Duration since log file creation date MaximumLogFiles int }
DiskWriterConfig ...
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is a logmanager base logger
func (*Logger) CheckErr ¶
CheckErr will close closer when called, and print an error if one is returned. This function is intended to be used in defer scenarios, where the error would otherwise be lost
func (*Logger) IsDebugEnabled ¶
IsDebugEnabled will return if debug is enabled, for this specific logger. note this is a bad mechanism to detect a general debug build state. for that you should use build flags
func (*Logger) IsError ¶
IsError is a good replacement for if err != nil { you can use if log.IsError(err) { and avoid having to write the same error logging code again and again. also much more useful error logging
func (*Logger) JSONify ¶
JSONify will attempt to jsonify the given structure useful for debugging shorthand for encoding/json marshalling but handling errors and conversion to string
func (*Logger) JSONifyIndent ¶
JSONifyIndent will attempt to jsonify the given structure - with opinionated indenting useful for debugging shorthand for encoding/json marshalling but handling errors and conversion to string
func (*Logger) PrintCaller ¶
PrintCaller prints caller of this function
func (*Logger) PrintStackTrace ¶
func (l *Logger) PrintStackTrace()
PrintStackTrace will print the current stack out to the info logger channel
func (*Logger) Recover ¶
Recover is intended to be used when recovering from panics, it will function similarly to IsError in that it will output a stacktrace, but it has additional handling to strip out the panic stack err is interface{} for convenience as that is what you will receieve from recover() example:
func mycode() (err error) { defer func() { if r := logger.Recover(recover()); r != nil{ err = r } }() panic(errors.New("oh no")) return nil }
in addition Recover will covert any string(er) type to an error if an error is not found
func (*Logger) SetLogLevel ¶
SetLogLevel will set the given log level
type SyslogWriter ¶
type SyslogWriter struct {
// contains filtered or unexported fields
}
SyslogWriter ...
func NewSyslogWriter ¶
func NewSyslogWriter(network, raddr string) (*SyslogWriter, error)
NewSyslogWriter returns a writer that will send log messages to a syslog server configured with the provied network, raddr strings. Passing in "" as the network will default to using default unix sockets
func (*SyslogWriter) BuildTheme ¶
func (w *SyslogWriter) BuildTheme(module string) ColorTheme
BuildTheme ...
func (*SyslogWriter) Log ¶
func (w *SyslogWriter) Log(level Level, _ ColorTheme, module, filename string, line int, timestamp time.Time, message string)
Log ...