Index | Files

package logging

import ""

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`.


Package Files


func Attach Uses

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 Uses

func Attachf(parent, child interface{}, format string, args ...interface{})

Attachf is Attach with built-in formatting.

func Fine Uses

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 Uses

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 Uses

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 Uses

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.

func Log Uses

func Log(format string, args ...interface{})

Log logs a formatted message.

func Register Uses

func Register(thing interface{}, names ...string)

Register attaches the given fields of a given *struct as '.' + name. This is just a shortcut for Register(&thing, &thing.field, ".field")... for a set of fields.

func SetFlags Uses

func SetFlags(flags int)

SetFlags sets flags to control logging output.

func SetOutput Uses

func SetOutput(output io.Writer)

SetOutput sets the output stream for logging.

Package logging imports 1 packages (graph) and is imported by 37 packages. Updated 2018-09-03. Refresh now. Tools for package owners.