Documentation
¶
Index ¶
- type Color
- type Entry
- func (e *Entry) Alert(v ...interface{})
- func (e *Entry) Alertf(m string, v ...interface{})
- func (e *Entry) Alertln(v ...interface{})
- func (e *Entry) Critical(v ...interface{})
- func (e *Entry) Criticalf(m string, v ...interface{})
- func (e *Entry) Criticalln(v ...interface{})
- func (e *Entry) Debug(v ...interface{})
- func (e *Entry) Debugf(m string, v ...interface{})
- func (e *Entry) Debugln(v ...interface{})
- func (e *Entry) Emergency(v ...interface{})
- func (e *Entry) Emergencyf(m string, v ...interface{})
- func (e *Entry) Emergencyln(v ...interface{})
- func (e *Entry) Error(v ...interface{})
- func (e *Entry) Errorf(m string, v ...interface{})
- func (e *Entry) Errorln(v ...interface{})
- func (e *Entry) Fatal(v ...interface{})
- func (e *Entry) Fatalf(m string, v ...interface{})
- func (e *Entry) Fatalln(v ...interface{})
- func (e *Entry) Info(v ...interface{})
- func (e *Entry) Infof(m string, v ...interface{})
- func (e *Entry) Infoln(v ...interface{})
- func (e *Entry) Notice(v ...interface{})
- func (e *Entry) Noticef(m string, v ...interface{})
- func (e *Entry) Noticeln(v ...interface{})
- func (e *Entry) Panic(v ...interface{})
- func (e *Entry) Panicf(m string, v ...interface{})
- func (e *Entry) Panicln(v ...interface{})
- func (e *Entry) Print(v ...interface{})
- func (e *Entry) Printf(m string, v ...interface{})
- func (e *Entry) Println(v ...interface{})
- func (e *Entry) Warning(v ...interface{})
- func (e *Entry) Warningf(m string, v ...interface{})
- func (e *Entry) Warningln(v ...interface{})
- func (e *Entry) WithField(key string, value interface{}) *Entry
- func (e *Entry) WithFields(fields Fields) *Entry
- type Fields
- type FileHandler
- type Handler
- type LogLevel
- type Logger
- func (l *Logger) AddHandler(n string, h Handler)
- func (l *Logger) Alert(v ...interface{})
- func (l *Logger) Alertf(m string, v ...interface{})
- func (l *Logger) Alertln(v ...interface{})
- func (l *Logger) Close()
- func (l *Logger) Critical(v ...interface{})
- func (l *Logger) Criticalf(m string, v ...interface{})
- func (l *Logger) Criticalln(v ...interface{})
- func (l *Logger) Debug(v ...interface{})
- func (l *Logger) Debugf(m string, v ...interface{})
- func (l *Logger) Debugln(v ...interface{})
- func (l *Logger) Emergency(v ...interface{})
- func (l *Logger) Emergencyf(m string, v ...interface{})
- func (l *Logger) Emergencyln(v ...interface{})
- func (l *Logger) Error(v ...interface{})
- func (l *Logger) Errorf(m string, v ...interface{})
- func (l *Logger) Errorln(v ...interface{})
- func (l *Logger) Fatal(v ...interface{})
- func (l *Logger) Fatalf(m string, v ...interface{})
- func (l *Logger) Fatalln(v ...interface{})
- func (l *Logger) GetHandler(n string) Handler
- func (l *Logger) Info(v ...interface{})
- func (l *Logger) Infof(m string, v ...interface{})
- func (l *Logger) Infoln(v ...interface{})
- func (l *Logger) Name() string
- func (l *Logger) Notice(v ...interface{})
- func (l *Logger) Noticef(m string, v ...interface{})
- func (l *Logger) Noticeln(v ...interface{})
- func (l *Logger) Panic(v ...interface{})
- func (l *Logger) Panicf(m string, v ...interface{})
- func (l *Logger) Panicln(v ...interface{})
- func (l *Logger) Print(v ...interface{})
- func (l *Logger) Printf(m string, v ...interface{})
- func (l *Logger) Println(v ...interface{})
- func (l *Logger) RemoveHandler(n string)
- func (l *Logger) Warning(v ...interface{})
- func (l *Logger) Warningf(m string, v ...interface{})
- func (l *Logger) Warningln(v ...interface{})
- func (l *Logger) WithField(key string, value interface{}) *Entry
- func (l *Logger) WithFields(fields Fields) *Entry
- type StdLogger
- type StdoutHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
Entry represents a log message going through the system
func (*Entry) Alertln ¶
func (e *Entry) Alertln(v ...interface{})
Alertln - Log Alert message with newline
func (*Entry) Criticalln ¶
func (e *Entry) Criticalln(v ...interface{})
Criticalln - Log Critical message with newline
func (*Entry) Debugln ¶
func (e *Entry) Debugln(v ...interface{})
Debugln - Log Debug message with newline
func (*Entry) Emergency ¶
func (e *Entry) Emergency(v ...interface{})
Emergency - Log Emergency message
func (*Entry) Emergencyf ¶
Emergencyf - Log formatted Emergency message
func (*Entry) Emergencyln ¶
func (e *Entry) Emergencyln(v ...interface{})
Emergencyln - Log Emergency message with newline
func (*Entry) Errorln ¶
func (e *Entry) Errorln(v ...interface{})
Errorln - Log Error message with newline
func (*Entry) Fatalln ¶
func (e *Entry) Fatalln(v ...interface{})
Fatalln - Log Fatal message with newline
func (*Entry) Infoln ¶
func (e *Entry) Infoln(v ...interface{})
Infoln - Log Info message with newline
func (*Entry) Noticeln ¶
func (e *Entry) Noticeln(v ...interface{})
Noticeln - Log Notice message with newline
func (*Entry) Panicln ¶
func (e *Entry) Panicln(v ...interface{})
Panicln - Log Panic message with newline
func (*Entry) Println ¶
func (e *Entry) Println(v ...interface{})
Println - Log Print message with newline
func (*Entry) Warningln ¶
func (e *Entry) Warningln(v ...interface{})
Warningln - Log Warning message with newline
func (*Entry) WithFields ¶
WithFields adds a map of fields to the Entry.
type FileHandler ¶
type FileHandler struct {
// contains filtered or unexported fields
}
FileHandler writes log messages to a file to a directory
func NewFileHandler ¶
func NewFileHandler(path string) (*FileHandler, error)
NewFileHandler takes the path and returns a FileHandler. If the path exists, file or directory mode will be Determined by what path is. If it doesn't exist, the mode will be file if path has an extension, otherwise it will be directory. In file mode, all log messages are written to a single file. In directory mode, each level is written to it's own file.
func (*FileHandler) Handles ¶
func (f *FileHandler) Handles(l LogLevel) bool
Handles returns whether the handler handles log level l.
func (*FileHandler) SetLevel ¶
func (f *FileHandler) SetLevel(l LogLevel)
SetLevel will set both the minimum and maximum log levels to l. This makes the handler only respond to the single level l.
func (*FileHandler) SetMaxLevel ¶
func (f *FileHandler) SetMaxLevel(l LogLevel)
SetMaxLevel will set the maximum log level the handler will handle.
func (*FileHandler) SetMinLevel ¶
func (f *FileHandler) SetMinLevel(l LogLevel)
SetMinLevel will set the minimum log level the handler will handle.
func (*FileHandler) WriteLog ¶
func (f *FileHandler) WriteLog(e *Entry)
WriteLog will write the log message to a file.
type Handler ¶
type Handler interface {
// Handles returns if it wants to handle a particular log level
// This can be used to suppress the higher log levels in production
Handles(level LogLevel) bool
// WriteLog actually logs the message using any system the Handler wishes.
// The Handler only needs to accept an Event.
WriteLog(e *Entry)
// Close is used to give a handler a chance to close any open resources
Close()
}
A Handler is an object that can be used by the Logger to log a message
type LogLevel ¶
type LogLevel int
LogLevel is used to compare levels in a consistant manner
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
A Logger takes a message and writes it to as many handlers as possible
func Classic ¶
Classic creates a logger with both the StdoutHandler and FileHandlers already added. If path is "", the FileHandler is not added. This is meant for convenience. The handlers use their default min and max levels. The StdoutHandler is named "stdout" and the FileHandler is named "file"
func Get ¶
Get returns an existing logger with name n or a new Logger if one doesn't exist. To ensure Loggers are never overwritten, it may be safer to always use this method.
func New ¶
New will create a new Logger with name n. If with the same name already exists, it will be replaced with the new logger.
func (*Logger) AddHandler ¶
AddHandler will add Handler h to the logger named n. If a handler with the same name already exists, it will be overwritten.
func (*Logger) Alertln ¶
func (l *Logger) Alertln(v ...interface{})
Alertln - Log Alert message with newline
func (*Logger) Close ¶
func (l *Logger) Close()
Close calls Close() on all the handlers then removes itself from the logger registry
func (*Logger) Critical ¶
func (l *Logger) Critical(v ...interface{})
Critical - Log Critical message
func (*Logger) Criticalln ¶
func (l *Logger) Criticalln(v ...interface{})
Criticalln - Log Critical message with newline
func (*Logger) Debugln ¶
func (l *Logger) Debugln(v ...interface{})
Debugln - Log Debug message with newline
func (*Logger) Emergency ¶
func (l *Logger) Emergency(v ...interface{})
Emergency - Log Emergency message
func (*Logger) Emergencyf ¶
Emergencyf - Log formatted Emergency message
func (*Logger) Emergencyln ¶
func (l *Logger) Emergencyln(v ...interface{})
Emergencyln - Log Emergency message with newline
func (*Logger) Errorln ¶
func (l *Logger) Errorln(v ...interface{})
Errorln - Log Error message with newline
func (*Logger) Fatalln ¶
func (l *Logger) Fatalln(v ...interface{})
Fatalln - Log Fatal message with newline
func (*Logger) GetHandler ¶
GetHandler will return handler with name n or nil if it doesn't exist.
func (*Logger) Infoln ¶
func (l *Logger) Infoln(v ...interface{})
Infoln - Log Info message with newline
func (*Logger) Noticeln ¶
func (l *Logger) Noticeln(v ...interface{})
Noticeln - Log Notice message with newline
func (*Logger) Panicln ¶
func (l *Logger) Panicln(v ...interface{})
Panicln - Log Panic message with newline
func (*Logger) Println ¶
func (l *Logger) Println(v ...interface{})
Println - Log Print message with newline
func (*Logger) RemoveHandler ¶
RemoveHandler will remove the handler named n.
func (*Logger) Warningln ¶
func (l *Logger) Warningln(v ...interface{})
Warningln - Log Warning message with newline
func (*Logger) WithFields ¶
WithFields creates an Entry with multiple fields
type StdLogger ¶
type StdLogger interface {
Print(...interface{})
Printf(string, ...interface{})
Println(...interface{})
Fatal(...interface{})
Fatalf(string, ...interface{})
Fatalln(...interface{})
Panic(...interface{})
Panicf(string, ...interface{})
Panicln(...interface{})
}
StdLogger is what your verbose-enabled library should take, that way it'll accept a stdlib logger and a verbose logger. There's no standard interface, this is the closest we get, unfortunately.
type StdoutHandler ¶
type StdoutHandler struct {
// contains filtered or unexported fields
}
StdoutHandler writes log message to standard out It even uses color!
func NewStdoutHandler ¶
func NewStdoutHandler() *StdoutHandler
NewStdoutHandler creates a new StdoutHandler, surprise!
func (*StdoutHandler) Handles ¶
func (s *StdoutHandler) Handles(l LogLevel) bool
Handles returns whether the handler handles log level l.
func (*StdoutHandler) SetLevel ¶
func (s *StdoutHandler) SetLevel(l LogLevel)
SetLevel will set both the minimum and maximum log levels to l. This makes the handler only respond to the single level l.
func (*StdoutHandler) SetMaxLevel ¶
func (s *StdoutHandler) SetMaxLevel(l LogLevel)
SetMaxLevel will set the maximum log level the handler will handle.
func (*StdoutHandler) SetMinLevel ¶
func (s *StdoutHandler) SetMinLevel(l LogLevel)
SetMinLevel will set the minimum log level the handler will handle.
func (*StdoutHandler) WriteLog ¶
func (s *StdoutHandler) WriteLog(e *Entry)
WriteLog writes the log message to standard output