Documentation ¶
Overview ¶
Package log is a simple wrapper around the standard library's log package and mainly adds log level support.
Index ¶
- Variables
- type Level
- type Logger
- func (l *Logger) Debug(v ...interface{})
- func (l *Logger) Debugf(format string, v ...interface{})
- func (l *Logger) Error(v ...interface{})
- func (l *Logger) Errorf(format string, v ...interface{})
- func (l *Logger) Fatal(v ...interface{})
- func (l *Logger) Fatalf(format string, v ...interface{})
- func (l *Logger) Info(v ...interface{})
- func (l *Logger) Infof(format string, v ...interface{})
- func (l *Logger) Level() Level
- func (l *Logger) SetLevel(level Level)
- func (l *Logger) SetLevelFromString(level string) error
- func (l *Logger) Warning(v ...interface{})
- func (l *Logger) Warningf(format string, v ...interface{})
Constants ¶
This section is empty.
Variables ¶
ErrInvalidLevel is returned when no valid logging level can be parsed by SetLevelFromString.
Functions ¶
This section is empty.
Types ¶
type Logger ¶
Logger contains the current logging level and the standard library's logger.
func New ¶
New creates a new logger. The out variable sets the log destination and level sets the logging level.
func NewDefaultLogger ¶
func NewDefaultLogger() *Logger
NewDefaultLogger creates a new logger with the default settings. The logging level is Info and it logs to standard error.
func (*Logger) Debug ¶
func (l *Logger) Debug(v ...interface{})
Debug prints to the logger when the logging level is at least Debug. Arguments are handled in the manner of fmt.Print.
func (*Logger) Debugf ¶
Debugf prints to the logger when the logging level is at least Debug. Arguments are handled in the manner of fmt.Printf.
func (*Logger) Error ¶
func (l *Logger) Error(v ...interface{})
Error prints to the logger when the logging level is at least Error. Arguments are handled in the manner of fmt.Print.
func (*Logger) Errorf ¶
Errorf prints to the logger when the logging level is at least Error. Arguments are handled in the manner of fmt.Printf.
func (*Logger) Fatal ¶
func (l *Logger) Fatal(v ...interface{})
Fatal prints to the logger and calls os.Exit(1). Arguments are handled in the manner of fmt.Print.
func (*Logger) Fatalf ¶
Fatalf prints to the logger and calls os.Exit(1). Arguments are handled in the manner of fmt.Printf.
func (*Logger) Info ¶
func (l *Logger) Info(v ...interface{})
Info prints to the logger when the logging level is at least Info. Arguments are handled in the manner of fmt.Print.
func (*Logger) Infof ¶
Infof prints to the logger when the logging level is at least Info. Arguments are handled in the manner of fmt.Printf.
func (*Logger) Level ¶
Level returns the current logging level of a logger.
func (*Logger) SetLevel ¶
SetLevel sets the logging level of a logger.
func (*Logger) SetLevelFromString ¶
SetLevelFromString parses the level from a string and sets the logging level. If it cannot parse a legitimate level from the level string, it will return ErrInvalidLevel.