lxd: github.com/lxc/lxd/shared/logging Index | Files

package logging

import "github.com/lxc/lxd/shared/logging"


Package Files

format.go log.go log_posix.go testing.go

func AddContext Uses

func AddContext(logger logger.Logger, ctx log.Ctx) logger.Logger

AddContext will return a copy of the logger with extra context added

func GetLogger Uses

func GetLogger(syslog string, logfile string, verbose bool, debug bool, customHandler log.Handler) (logger.Logger, error)

GetLogger returns a logger suitable for using as logger.Log.

func LogfmtFormat Uses

func LogfmtFormat() log.Format

LogfmtFormat return a formatter for a text log file

func SetLogger Uses

func SetLogger(newLogger logger.Logger) func()

SetLogger installs the given logger as global logger. It returns a function that can be used to restore whatever logger was installed beforehand.

func TerminalFormat Uses

func TerminalFormat() log.Format

TerminalFormat formats log records optimized for human readability on a terminal with color-coded level output and terser human friendly timestamp. This format should only be used for interactive programs or while developing.

[TIME] [LEVEL] MESAGE key=value key=value ...


[May 16 20:58:45] [DBUG] remove route ns=haproxy addr=

func Testing Uses

func Testing(t *testing.T) func()

Testing installs a global logger that emits messages using the t.Logf method of the given testing.T instance.

Return a function that can be used to restore whatever global logger was previously in place.

func WaitRecord Uses

func WaitRecord(ch chan *log.Record, timeout time.Duration) *log.Record

WaitRecord blocks until a log.Record is received on the given channel. It returns the emitted record, or nil if no record was received within the given timeout. Useful in conjunction with log.ChannelHandler, for asynchronous testing.

Package logging imports 13 packages (graph) and is imported by 47 packages. Updated 2018-11-05. Refresh now. Tools for package owners.