Documentation ¶
Index ¶
- Variables
- type Level
- type Logger
- func (l *Logger) AddWriter(wtr io.WriteCloser) error
- func (l *Logger) Close() (err error)
- func (l *Logger) Critical(f string, args ...interface{}) error
- func (l *Logger) Debug(f string, args ...interface{}) error
- func (l *Logger) DeleteWriter(wtr io.Writer) error
- func (l *Logger) Error(f string, args ...interface{}) error
- func (l *Logger) Fatal(f string, args ...interface{})
- func (l *Logger) FatalCode(code int, f string, args ...interface{})
- func (l *Logger) GetLevel() Level
- func (l *Logger) Info(f string, args ...interface{}) error
- func (l *Logger) SetLevel(lvl Level) error
- func (l *Logger) SetLevelString(s string) error
- func (l *Logger) Warn(f string, args ...interface{}) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotOpen = errors.New("Logger is not open") ErrInvalidLevel = errors.New("Log level is invalid") )
Functions ¶
This section is empty.
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func New ¶
func New(wtr io.WriteCloser) *Logger
New creates a new logger with the given writer at log level INFO
func NewDiscardLogger ¶
func NewDiscardLogger() *Logger
func NewFile ¶
NewFile creates a new logger with the first writer being a file The file is created if it does not exist, and is opened in append mode it is safe to use NewFile on existing logs
func (*Logger) AddWriter ¶
func (l *Logger) AddWriter(wtr io.WriteCloser) error
Add a new writer which will get all the log lines as they are handled
func (*Logger) Close ¶
Close closes the logger and all currently associated writers writers that have been deleted are NOT closed
func (*Logger) Critical ¶
Critical writes a CRITICALinfo level log to the underlying writer, if the logging level is higher than DEBUG no action is taken
func (*Logger) Debug ¶
Debug writes a DEBUG level log to the underlying writer, if the logging level is higher than DEBUG no action is taken
func (*Logger) DeleteWriter ¶
DeleteWriter removes a writer from the logger, it will not be closed on logging Close
func (*Logger) Error ¶
Error writes an ERROR level log to the underlying writer, if the logging level is higher than DEBUG no action is taken
func (*Logger) FatalCode ¶
FatalCode is identical to a log.Fatal, except it allows for controlling the exit code
func (*Logger) Info ¶
Info writes an INFO level log to the underlying writer, if the logging level is higher than DEBUG no action is taken
func (*Logger) SetLevel ¶
SetLevel sets the log level, Off disables logging and any logging call that is less than the level current level are not logged
func (*Logger) SetLevelString ¶
SetLevelString sets the log level using a string, this is a helper function so that you can just hand the config file value directly in