logging

package
Version: v0.0.0-...-f1791b3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2022 License: Apache-2.0 Imports: 1 Imported by: 37

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

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.

func Log

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

Log logs a formatted message.

func Register

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

func SetFlags(flags int)

SetFlags sets flags to control logging output.

func SetOutput

func SetOutput(output io.Writer)

SetOutput sets the output stream for logging.

Types

This section is empty.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL