Documentation ¶
Overview ¶
Package log implements a small wrapper around the std lib log package. It implements log levels by prefixing the logs with [INFO], [DEBUG], [WARNING] or [ERROR]. Debug logging is available and enabled if the *debug* plugin is used.
log.Info("this is some logging"), will log on the Info level.
log.Debug("this is debug output"), will log in the Debug level, etc.
Index ¶
- Variables
- func Debug(v ...interface{})
- func Debugf(format string, v ...interface{})
- func DeregisterListener(old Listener) error
- func Discard()
- func Error(v ...interface{})
- func Errorf(format string, v ...interface{})
- func Fatal(v ...interface{})
- func Fatalf(format string, v ...interface{})
- func Info(v ...interface{})
- func Infof(format string, v ...interface{})
- func RegisterListener(new Listener) error
- func Warning(v ...interface{})
- func Warningf(format string, v ...interface{})
- type Listener
- type P
- func (p P) Debug(v ...interface{})
- func (p P) Debugf(format string, v ...interface{})
- func (p P) Error(v ...interface{})
- func (p P) Errorf(format string, v ...interface{})
- func (p P) Fatal(v ...interface{})
- func (p P) Fatalf(format string, v ...interface{})
- func (p P) Info(v ...interface{})
- func (p P) Infof(format string, v ...interface{})
- func (p P) Warning(v ...interface{})
- func (p P) Warningf(format string, v ...interface{})
Constants ¶
This section is empty.
Variables ¶
var D = &d{}
D controls whether we should output debug logs. If true, we do, once set it can not be unset.
Functions ¶
func Debug ¶
func Debug(v ...interface{})
Debug is equivalent to log.Print(), but prefixed with "[DEBUG] ". It only outputs something if D is true.
func Debugf ¶
func Debugf(format string, v ...interface{})
Debugf is equivalent to log.Printf(), but prefixed with "[DEBUG] ". It only outputs something if D is true.
func DeregisterListener ¶
DeregisterListener deregister a listener object.
func Error ¶
func Error(v ...interface{})
Error is equivalent to log.Print, but prefixed with "[ERROR] ".
func Errorf ¶
func Errorf(format string, v ...interface{})
Errorf is equivalent to log.Printf, but prefixed with "[ERROR] ".
func Fatal ¶
func Fatal(v ...interface{})
Fatal is equivalent to log.Print, but prefixed with "[FATAL] ", and calling os.Exit(1).
func Fatalf ¶
func Fatalf(format string, v ...interface{})
Fatalf is equivalent to log.Printf, but prefixed with "[FATAL] ", and calling os.Exit(1)
func Info ¶
func Info(v ...interface{})
Info is equivalent to log.Print, but prefixed with "[INFO] ".
func Infof ¶
func Infof(format string, v ...interface{})
Infof is equivalent to log.Printf, but prefixed with "[INFO] ".
func RegisterListener ¶
RegisterListener register a listener object.
Types ¶
type Listener ¶
type Listener interface { Name() string Debug(plugin string, v ...interface{}) Debugf(plugin string, format string, v ...interface{}) Info(plugin string, v ...interface{}) Infof(plugin string, format string, v ...interface{}) Warning(plugin string, v ...interface{}) Warningf(plugin string, format string, v ...interface{}) Error(plugin string, v ...interface{}) Errorf(plugin string, format string, v ...interface{}) Fatal(plugin string, v ...interface{}) Fatalf(plugin string, format string, v ...interface{}) }
Listener listens for all log prints of plugin loggers aka loggers with plugin name. When a plugin logger gets called, it should first call the same method in the Listener object. A usage example is, the external plugin k8s_event will replicate log prints to Kubernetes events.
type P ¶
type P struct {
// contains filtered or unexported fields
}
P is a logger that includes the plugin doing the logging.
func NewWithPlugin ¶
NewWithPlugin returns a logger that includes "plugin/name: " in the log message. I.e [INFO] plugin/<name>: message.