Documentation ¶
Overview ¶
Package logger implements an hierachical logger used by other packages.
Index ¶
- Constants
- func AddWriter(writer LoggerWriter)
- func Debug(format string, v ...interface{})
- func Error(format string, v ...interface{})
- func Fatal(format string, v ...interface{})
- func Info(format string, v ...interface{})
- func Log(level int, format string, v ...interface{})
- func SetFormat(format int)
- func SetLevel(level int)
- func SetLevelByName(lname string)
- func Warn(format string, v ...interface{})
- type Console
- type Event
- type File
- type Logger
- func (self *Logger) AddWriter(writer LoggerWriter)
- func (self *Logger) Debug(format string, v ...interface{})
- func (self *Logger) EnableChild(name string, state bool)
- func (self *Logger) Error(format string, v ...interface{})
- func (self *Logger) Fatal(format string, v ...interface{})
- func (self *Logger) Info(format string, v ...interface{})
- func (self *Logger) Log(level int, format string, v ...interface{})
- func (self *Logger) RemoveWriter(writer LoggerWriter)
- func (self *Logger) SetFormat(format int)
- func (self *Logger) SetLevel(level int)
- func (self *Logger) SetLevelByName(lname string) error
- func (self *Logger) Warn(format string, v ...interface{})
- type LoggerWriter
- type Net
Constants ¶
const ( DEBUG = iota INFO WARN ERROR FATAL )
Levels to filter log output
const ( // Show date FDATE = 1 << iota // Show hour, minutes and seconds FTIME // Show milliseconds after FTIME FMILIS // Show microseconds after FTIME FMICROS // Show nanoseconfs after TIME FNANOS )
Flags used to format the log date/time
Variables ¶
This section is empty.
Functions ¶
func AddWriter ¶
func AddWriter(writer LoggerWriter)
func SetLevelByName ¶
func SetLevelByName(lname string)
Types ¶
type Console ¶
type Console struct {
// contains filtered or unexported fields
}
logger Console writer type
func NewConsole ¶
NewConsole creates and returns a new logger Console writer If color is true, this writer uses Ansi codes to write log messages in color accordingly to its level.
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
Logger event passed from the logger to its writers.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger Object state structure
func New ¶
New() creates and returns a new logger with the specified name. If a parent logger is specified, the created logger inherits the parent's configuration.
func (*Logger) AddWriter ¶
func (self *Logger) AddWriter(writer LoggerWriter)
AddWriter adds a writer to the current outputs of this logger.
func (*Logger) EnableChild ¶
EnableChild enables or disables this logger child logger with the specified name.
func (*Logger) RemoveWriter ¶
func (self *Logger) RemoveWriter(writer LoggerWriter)
RemoveWriter removes the specified writer from the current outputs of this logger.
func (*Logger) SetLevel ¶
SetLevel set the current level of this logger Only log messages with levels with the same or higher priorities than the current level will be emitted.
func (*Logger) SetLevelByName ¶
SetLevelByName sets the current level of this logger by level name: debug|info|warn|error|fatal (case ignored.) Only log messages with levels with the same or higher priorities than the current level will be emitted.
type LoggerWriter ¶
type LoggerWriter interface { Write(*Event) Close() Sync() }
Interface for all logger writers