Documentation ¶
Overview ¶
Package logging provides logging functions for use in the bar and modules. It uses build tags to provide nop functions in the default case, and actual logging functions when built with `-tags debuglog`.
Index ¶
- func Attach(parent, child interface{}, name string)
- func Attachf(parent, child interface{}, format string, args ...interface{})
- func Fine(format string, args ...interface{})
- func ID(thing interface{}) string
- func Label(thing interface{}, label string)
- func Labelf(thing interface{}, format string, args ...interface{})
- func Log(format string, args ...interface{})
- func Register(thing interface{}, names ...string)
- func SetFlags(flags int)
- func SetOutput(output io.Writer)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Attach ¶
func Attach(parent, child interface{}, name string)
Attach attaches an object as a named member of a different object. This is useful when a generic type (e.g. chan) is used within a more specific type (e.g. Module). Typical usage would be:
logging.Attach(m, m.scheduler, "refresher")
where m is a module, m.scheduler is a timing.Scheduler. This will make subsequent log statements that use that scheduler as a context (even from a different package, e.g. timing) print it as module#1.refresher instead of timing.Scheduler#45.
func Attachf ¶
func Attachf(parent, child interface{}, format string, args ...interface{})
Attachf is Attach with built-in formatting.
func Fine ¶
func Fine(format string, args ...interface{})
Fine logs a formatted message if fine logging is enabled for the calling module. Enable fine logging using the commandline flag, `--finelog=$module1,$module2`. [Requires debug logging].
func ID ¶
func ID(thing interface{}) string
ID returns a unique name for the given value of the form 'type'#'index' for addressable types. This provides log statements with additional context and separates logs from multiple instances of the same type.
func Label ¶
func Label(thing interface{}, label string)
Label adds an additional label to thing, incorporated as part of its identifier, to provide more useful information than just #0, #1, ... For example, a diskspace module might use:
logging.Label(m, "sda1")
which would make its ID mod:diskspace.Module#0<sda1>, making it easier to track in logs.
func Labelf ¶
func Labelf(thing interface{}, format string, args ...interface{})
Labelf is Label with built-in formatting. Because all logging functions are no-ops without debuglog, having the sprintf be part of the Labelf function means that it will only be executed if debug logging is on.
Types ¶
This section is empty.