Documentation
¶
Index ¶
- Constants
- func AddHandler(h Handler)
- func Debug(v ...interface{})
- func Debugf(f string, v ...interface{})
- func Debugln(v ...interface{})
- func Debugw(msg string, v ...interface{})
- func DisableColor()
- func DisableLevelColor(level int)
- func DisableLogFormat()
- func EnableColor()
- func EnableLevelColor(level int)
- func EnableLogFormat()
- func Error(v ...interface{})
- func Errorf(f string, v ...interface{})
- func Errorln(v ...interface{})
- func Errorw(msg string, v ...interface{})
- func Fatal(v ...interface{})
- func Fatalf(f string, v ...interface{})
- func Fatalln(v ...interface{})
- func Fatalw(msg string, v ...interface{})
- func GetFlags() int
- func GetVerbosity() int
- func Info(v ...interface{})
- func Infof(f string, v ...interface{})
- func Infoln(v ...interface{})
- func Infow(msg string, v ...interface{})
- func Log(p int, l *Logger, level int, f string, v ...interface{})
- func SetFlags(flag int)
- func SetLevelOutput(level int, w io.Writer)
- func SetOutput(w io.Writer)
- func SetTimeFormat(format string)
- func SetVerbosity(v int)
- func Warn(v ...interface{})
- func Warnf(f string, v ...interface{})
- func Warnln(v ...interface{})
- func Warnw(msg string, v ...interface{})
- type Field
- type Fields
- type Handler
- type Logger
- func (l *Logger) AddHandler(h Handler)
- func (l *Logger) Debug(v ...interface{})
- func (l *Logger) Debugf(f string, v ...interface{})
- func (l *Logger) Debugln(v ...interface{})
- func (l *Logger) Debugw(msg string, v ...interface{})
- func (l *Logger) DisableColor()
- func (l *Logger) DisableLevelColor(level int)
- func (l *Logger) DisableLogFormat()
- func (l *Logger) EnableColor()
- func (l *Logger) EnableLevelColor(level int)
- func (l *Logger) EnableLogFormat()
- func (l *Logger) Error(v ...interface{})
- func (l *Logger) Errorf(f string, v ...interface{})
- func (l *Logger) Errorln(v ...interface{})
- func (l *Logger) Errorw(msg string, v ...interface{})
- func (l *Logger) Fatal(v ...interface{})
- func (l *Logger) Fatalf(f string, v ...interface{})
- func (l *Logger) Fatalln(v ...interface{})
- func (l *Logger) Fatalw(msg string, v ...interface{})
- func (l *Logger) GetFlags() int
- func (l *Logger) GetVerbosity() int
- func (l *Logger) Info(v ...interface{})
- func (l *Logger) Infof(f string, v ...interface{})
- func (l *Logger) Infoln(v ...interface{})
- func (l *Logger) Infow(msg string, v ...interface{})
- func (l *Logger) SetFlags(flag int)
- func (l *Logger) SetLevelOutput(level int, w io.Writer)
- func (l *Logger) SetOutput(w io.Writer)
- func (l *Logger) SetTimeFormat(format string)
- func (l *Logger) SetVerbosity(v int)
- func (l *Logger) Warn(v ...interface{})
- func (l *Logger) Warnf(f string, v ...interface{})
- func (l *Logger) Warnln(v ...interface{})
- func (l *Logger) Warnw(msg string, v ...interface{})
- type Mutex
Constants ¶
const ( // NONE = 0 NONE = iota // FATAL = 1 FATAL // ERROR = 2 ERROR // WARN = 3 WARN // INFO = 4 INFO // DEBUG = 5 DEBUG )
const ( // PRINT = 0 PRINT = iota // PRINTF = 1 PRINTF // PRINTLN = 2 PRINTLN // PRINTW = 3 PRINTW )
const ( // FTIMESTAMP enables timestamp field in message log FTIMESTAMP = 1 << iota // FCALLER enables caller field in message log FCALLER // FFULLSTRUCTUREDLOG enables structured log for all fields in message log FFULLSTRUCTUREDLOG )
Variables ¶
This section is empty.
Functions ¶
func AddHandler ¶ added in v0.2.0
func AddHandler(h Handler)
AddHandler add a new handler in the handler list
func DisableLevelColor ¶
func DisableLevelColor(level int)
DisableLevelColor enables color for a specific level
func DisableLogFormat ¶
func DisableLogFormat()
DisableLogFormat disables format log of message. It will print unformatted msg as normally like with any function printf without color or prefix etc.
func EnableLevelColor ¶
func EnableLevelColor(level int)
EnableLevelColor enables color for a specific level
func EnableLogFormat ¶
func EnableLogFormat()
EnableLogFormat enables format log of message. It will print msg as a log with color or prefix etc.
func Fatalf ¶
func Fatalf(f string, v ...interface{})
Fatalf logs with Printf() followed by os.Exit(1)
func Log ¶
Log wraps print function but using goroutine and waitgroup to have a synchronization of logs.
func SetLevelOutput ¶
SetLevelOutput sets output destination for a specific level
func SetTimeFormat ¶
func SetTimeFormat(format string)
SetTimeFormat sets timestamp with the given format
func SetVerbosity ¶
func SetVerbosity(v int)
SetVerbosity sets log level. If verbose < NONE, it will be set to NONE. If verbose > DEBUG, it will be set to DEBUG
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is a wrapper of go log integrating log level
func NewLogger ¶
func NewLogger() *Logger
NewLogger returns a new instance logger By default, it uses stderr for error and stdout for other levels
func (*Logger) AddHandler ¶ added in v0.2.0
AddHandler add a new handler in the handler list
func (*Logger) DisableColor ¶
func (l *Logger) DisableColor()
DisableColor disables color for all log levels
func (*Logger) DisableLevelColor ¶
DisableLevelColor enables color for a specific level
func (*Logger) DisableLogFormat ¶
func (l *Logger) DisableLogFormat()
DisableLogFormat disables format log of message. It will print unformatted msg as normally like with any function printf without color or prefix etc.
func (*Logger) EnableColor ¶
func (l *Logger) EnableColor()
EnableColor enables color for all log levels
func (*Logger) EnableLevelColor ¶
EnableLevelColor enables color for a specific level
func (*Logger) EnableLogFormat ¶
func (l *Logger) EnableLogFormat()
EnableLogFormat enables format log of message. It will print msg as a log with color or prefix etc.
func (*Logger) Fatal ¶
func (l *Logger) Fatal(v ...interface{})
Fatal logs with Print() followed by os.Exit(1)
func (*Logger) Fatalln ¶
func (l *Logger) Fatalln(v ...interface{})
Fatalln logs with Println() followed by os.Exit(1)
func (*Logger) GetVerbosity ¶
GetVerbosity returns the current log level
func (*Logger) SetLevelOutput ¶
SetLevelOutput sets output destination for a specific level
func (*Logger) SetTimeFormat ¶
SetTimeFormat sets timestamp with the given format
func (*Logger) SetVerbosity ¶
SetVerbosity sets log level. If verbose < NONE, it will be set to NONE. If verbose > DEBUG, it will be set to DEBUG
type Mutex ¶ added in v0.2.0
type Mutex struct {
// contains filtered or unexported fields
}
Mutex is struct of mutex and locked to know if mutex is locked or not
func (*Mutex) LockOnce ¶ added in v0.2.0
func (m *Mutex) LockOnce()
LockOnce locks mutex if it isnt yet
func (*Mutex) UnlockOnce ¶ added in v0.2.0
func (m *Mutex) UnlockOnce()
UnlockOnce unlocks mutex if it is