Documentation ¶
Overview ¶
Package log implements leveling and teeing on top of Go's standard logs package. As with the standard log package, this package defines a standard logger available as a package global and via package functions.
Index ¶
- Variables
- func At(level Level) bool
- func Debug(v ...interface{})
- func Debugf(format string, args ...interface{})
- func Error(v ...interface{})
- func Errorf(format string, args ...interface{})
- func Fatal(v ...interface{})
- func Fatalf(format string, v ...interface{})
- func Print(v ...interface{})
- func Printf(format string, args ...interface{})
- type Level
- type Logger
- func (l *Logger) At(level Level) bool
- func (l *Logger) Debug(v ...interface{})
- func (l *Logger) Debugf(format string, args ...interface{})
- func (l *Logger) Error(v ...interface{})
- func (l *Logger) Errorf(format string, args ...interface{})
- func (l *Logger) Print(v ...interface{})
- func (l *Logger) Printf(format string, args ...interface{})
- func (l *Logger) Tee(out Outputter, prefix string) *Logger
- type Outputter
Constants ¶
This section is empty.
Variables ¶
Std is the standard global logger. It is used by the package level logging functions.
Functions ¶
func Debug ¶
func Debug(v ...interface{})
Debug formats a message in the manner of fmt.Sprint and logs it to the standard (debug) logger.
func Debugf ¶
func Debugf(format string, args ...interface{})
Debugf formats a message in the manner of fmt.Sprintf and logs it to the standard (debug) logger.
func Error ¶
func Error(v ...interface{})
Error formats a message in the manner of fmt.Sprint and logs it to the standard (error) logger.
func Errorf ¶
func Errorf(format string, args ...interface{})
Errorf formats a message in the manner of fmt.Sprintf and logs it to the standard (error) logger.
func Fatal ¶
func Fatal(v ...interface{})
Fatal formats a message in the manner of fmt.Print, outputs it to the standard outputter (always), and then calls os.Exit(1).
func Fatalf ¶
func Fatalf(format string, v ...interface{})
Fatalf formats a message in the manner of fmt.Printf, outputs it to the standard outputter (always), and then calls os.Exit(1).
Types ¶
type Level ¶
type Level int
Level defines the level of logging. Higher levels are more verbose.
func LevelFromString ¶
type Logger ¶
type Logger struct { // Outputter receives all log messages at or below the Logger's // current level. Outputter // Level defines the publishing level of this Logger. Level Level Parent *Logger // contains filtered or unexported fields }
A Logger receives log messages at multiple levels, and publishes those messages to its outputter if the level (or logger) is active. Nil Loggers ignore all log messages.
func New ¶
New creates a new Logger that publishes messsages at or below the provided level to the provided outputter.
func NewWithLevelPrefix ¶
NewWithLevelPrefix creates a new Logger that prefixes each log with the logging level it was output with. Logs at all levels are output.
func (*Logger) Debug ¶
func (l *Logger) Debug(v ...interface{})
Debug formats a message in the manner of fmt.Print and publishes it to the logger at DebugLevel.
func (*Logger) Debugf ¶
Debugf formats a message in the manner of fmt.Printf and publishes it to the logger at DebugLevel.
func (*Logger) Error ¶
func (l *Logger) Error(v ...interface{})
Error formats a message in the manner of fmt.Print and publishes it to the logger at ErrorLevel.
func (*Logger) Errorf ¶
Errorf formats a message in the manner of fmt.Printf and publishes it to the logger at ErrorLevel.
func (*Logger) Print ¶
func (l *Logger) Print(v ...interface{})
Print formats a message in the manner of fmt.Print and publishes it to the logger at InfoLevel.
func (*Logger) Printf ¶
Printf formats a message in the manner of fmt.Printf and publishes it to the logger at InfoLevel.
type Outputter ¶
An Outputter receives published log messages. Go's *log.Logger implements Outputter.
func MultiOutputter ¶
MultiOutputter returns an Outputter that outputs each message to all the provided outputters.