Documentation ¶
Overview ¶
Package logger implements an hierarchical 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 (l *Logger) AddWriter(writer LoggerWriter)
- func (l *Logger) Debug(format string, v ...interface{})
- func (l *Logger) EnableChild(name string, state bool)
- func (l *Logger) Error(format string, v ...interface{})
- func (l *Logger) Fatal(format string, v ...interface{})
- func (l *Logger) Info(format string, v ...interface{})
- func (l *Logger) Log(level int, format string, v ...interface{})
- func (l *Logger) RemoveWriter(writer LoggerWriter)
- func (l *Logger) SetFormat(format int)
- func (l *Logger) SetLevel(level int)
- func (l *Logger) SetLevelByName(lname string) error
- func (l *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)
AddWriter adds a writer to the current outputs of the default logger.
func SetFormat ¶
func SetFormat(format int)
SetFormat sets the date/time message format of the default logger.
func SetLevel ¶
func SetLevel(level int)
SetLevel sets the current level of the default logger. Only log messages with levels with the same or higher priorities than the current level will be emitted.
func SetLevelByName ¶
func SetLevelByName(lname string)
SetLevelByName sets the current level of the default 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.
Types ¶
type Console ¶
type Console struct {
// contains filtered or unexported fields
}
Console is a console writer used for logging.
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
}
Event is a logger event passed from the logger to its writers.
type File ¶
type File struct {
// contains filtered or unexported fields
}
File is a file writer used for logging.
func NewFile ¶
NewFile creates and returns a pointer to a new File object along with any error that occurred.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger Object state structure
var Default *Logger
Default logger and global mutex
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 (l *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 (l *Logger) RemoveWriter(writer LoggerWriter)
RemoveWriter removes the specified writer from the current outputs of this logger.
func (*Logger) SetLevel ¶
SetLevel sets 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() }
LoggerWriter is the interface for all logger writers