Documentation ¶
Overview ¶
Package simplexlog simple wrapper for the standard log package, that adds log level. simplexlog is concurrent safe.
Index ¶
- Constants
- func SetAllDefault(c Config) func(*Logger)
- func SetCritical(c Config) func(*Logger)
- func SetDebug(c Config) func(*Logger)
- func SetDefault(c Config) func(*Logger)
- func SetError(c Config) func(*Logger)
- func SetErrorDefault(c Config) func(*Logger)
- func SetInfo(c Config) func(*Logger)
- func SetNotice(c Config) func(*Logger)
- func SetOutput(level LogLevel, w io.Writer) func(*Logger)
- func SetTrace(c Config) func(*Logger)
- func SetWarning(o Config) func(*Logger)
- type Config
- type LogLevel
- type Logger
- func (l *Logger) Critical(a ...interface{})
- func (l *Logger) CriticalLogger() *log.Logger
- func (l *Logger) Criticalf(format string, v ...interface{})
- func (l *Logger) Debug(a ...interface{})
- func (l *Logger) DebugLogger() *log.Logger
- func (l *Logger) Debugf(format string, v ...interface{})
- func (l *Logger) Error(a ...interface{})
- func (l *Logger) ErrorLogger() *log.Logger
- func (l *Logger) Errorf(format string, v ...interface{})
- func (l *Logger) Fatal(a ...interface{})
- func (l *Logger) Fatalf(format string, v ...interface{})
- func (l *Logger) Info(a ...interface{})
- func (l *Logger) InfoLogger() *log.Logger
- func (l *Logger) Infof(format string, v ...interface{})
- func (l *Logger) Level() LogLevel
- func (l *Logger) LevelName() string
- func (l *Logger) LevelNames() string
- func (l *Logger) Notice(a ...interface{})
- func (l *Logger) NoticeLogger() *log.Logger
- func (l *Logger) Noticef(format string, v ...interface{})
- func (l *Logger) Panic(a ...interface{})
- func (l *Logger) Panicf(format string, v ...interface{})
- func (l *Logger) SetFlags(level LogLevel, flag int)
- func (l *Logger) SetLabel(level LogLevel, label string)
- func (l *Logger) SetOutput(level LogLevel, w io.Writer)
- func (l *Logger) SwitchTo(level interface{})
- func (l *Logger) Trace(a ...interface{})
- func (l *Logger) TraceLogger() *log.Logger
- func (l *Logger) Tracef(format string, v ...interface{})
- func (l *Logger) Warning(a ...interface{})
- func (l *Logger) WarningLogger() *log.Logger
- func (l *Logger) Warningf(format string, v ...interface{})
Constants ¶
const ( // Critical log level Critical LogLevel = iota // Error log level Error // Warning log level Warning // Notice log level Notice // Info log level Info // Debug log level Debug // Trace log level Trace // All log level All // LevelCritical critical level LevelCritical = "CRITICAL" // LevelError error level LevelError = "ERROR" // LevelWarning warning level LevelWarning = "WARNING" // LevelNotice notice level LevelNotice = "NOTICE" // LevelInfo info level LevelInfo = "INFO" // LevelDebug debug level LevelDebug = "DEBUG" // LevelTrace trace level LevelTrace = "TRACE" // LevelAll all level LevelAll = "ALL" )
const ( // DefaultLogFlags default flagsfor log DefaultLogFlags = log.Ldate | log.Ltime | log.Lmicroseconds )
Variables ¶
This section is empty.
Functions ¶
func SetAllDefault ¶
SetAllDefault set the options of default logger used by all the log level
func SetCritical ¶
SetCritical set the options of critical logger
func SetDefault ¶
SetDefault set the options of default logger used by all log level except Error, Critical, Fatal and Panic
func SetErrorDefault ¶
SetErrorDefault set the options of default logger for error (used by Error, Critical level and by Fatal and Panic)
func SetWarning ¶
SetWarning set the option of warning logger
Types ¶
type Config ¶
type Config struct { // Out is the output writer Out io.Writer // Label the prefix of a log line Label string // Flags are the same combination of flag of standard log package Flags int }
Config log option
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger simple log wrapper
func New ¶
New return a new logger. By default, all logs message are output to os.Stdout, except "error" and "critical" message that are logged to os.Stderr.
func (*Logger) Critical ¶
func (l *Logger) Critical(a ...interface{})
Critical print to the Critical logger
func (*Logger) CriticalLogger ¶
CriticalLogger return the error logger
func (*Logger) DebugLogger ¶
DebugLogger return the debug logger
func (*Logger) ErrorLogger ¶
ErrorLogger Return the error logger
func (*Logger) Fatal ¶
func (l *Logger) Fatal(a ...interface{})
Fatal print fatal message to critical logger, followed by call to os.Exit(1)
func (*Logger) Fatalf ¶
Fatalf print fatal message, accordind to format, to critical logger, followed by call to os.Exit(1)
func (*Logger) InfoLogger ¶
InfoLogger return the info logger
func (*Logger) LevelNames ¶
LevelNames return all the availables level name, from the most specific (little data) to the least specific (all data)
func (*Logger) NoticeLogger ¶
NoticeLogger return the error logger
func (*Logger) Panic ¶
func (l *Logger) Panic(a ...interface{})
Panic print panic message to the critical logger, followed by call to panic()
func (*Logger) Panicf ¶
Panicf print panic message to the critical logger, followed by call to panic()
func (*Logger) SwitchTo ¶
func (l *Logger) SwitchTo(level interface{})
SwitchTo change the log level, level can be of type string (must match, case insensitive, level name like LevelTrace, LevelCritical etc), int or LogLevel to take effect
func (*Logger) TraceLogger ¶
TraceLogger return the trace logger
func (*Logger) Warning ¶
func (l *Logger) Warning(a ...interface{})
Warning print to the Warning logger
func (*Logger) WarningLogger ¶
WarningLogger return the warning logger