flogging

package
v1.0.0-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2017 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultLevel

func DefaultLevel() logging.Level

DefaultLevel returns the fallback value for loggers to use if parsing fails

func GetModuleLevel

func GetModuleLevel(module string) (string, error)

GetModuleLevel gets the current logging level for the specified module

func InitFromSpec

func InitFromSpec(spec string) logging.Level

LoggingInit initializes the logging based on the supplied spec, it is exposed externally so that consumers of the flogging package who do not wish to use the default config structure may parse their own logging specification

func InitFromViper

func InitFromViper(command string)

LoggingInitFromViper is a 'hook' called at the beginning of command processing to parse logging-related options specified either on the command-line or in config files. Command-line options take precedence over config file options, and can also be passed as suitably-named environment variables. To change module logging levels at runtime call `logging.SetLevel(level, module)`. To debug this routine include logging=debug as the first term of the logging specification. TODO this initialization is specific to the peer config format. The viper references should be removed, and this path should be moved into the peer

func SetLoggingFormat

func SetLoggingFormat(formatString string, output io.Writer)

SetLoggingFormat sets the logging format and the location of the log output

Example
// initializes logging backend for testing and sets
// time to 1970-01-01 00:00:00.000 UTC
logging.InitForTesting(flogging.DefaultLevel())

logFormat := "%{time:2006-01-02 15:04:05.000 MST} [%{module}] %{shortfunc} -> %{level:.4s} %{id:03x} %{message}"
flogging.SetLoggingFormat(logFormat, os.Stdout)

logger := logging.MustGetLogger("floggingTest")
logger.Infof("test")
Output:

1970-01-01 00:00:00.000 UTC [floggingTest] ExampleSetLoggingFormat -> INFO 001 test
Example (Second)
// initializes logging backend for testing and sets
// time to 1970-01-01 00:00:00.000 UTC
logging.InitForTesting(flogging.DefaultLevel())

logFormat := "%{time:15:04:05.000} [%{module}] %{shortfunc} -> %{level:.4s} %{id:03x} %{message}"
flogging.SetLoggingFormat(logFormat, os.Stdout)

logger := logging.MustGetLogger("floggingTest")
logger.Infof("test")
Output:

00:00:00.000 [floggingTest] ExampleSetLoggingFormat_second -> INFO 001 test

func SetModuleLevel

func SetModuleLevel(module string, logLevel string) (string, error)

SetModuleLevel sets the logging level for the specified module. This is currently only called from admin.go but can be called from anywhere in the code on a running peer to dynamically change the log level for the module.

Types

This section is empty.

Jump to

Keyboard shortcuts

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