Documentation
¶
Index ¶
- func GetAllLevels() map[string]Level
- func GetSpec() string
- func HideCallerInfo(module string, level Level)
- func Initialize(l LoggerProvider)
- func IsCallerInfoEnabled(module string, level Level) bool
- func IsEnabledFor(module string, level Level) bool
- func ParseString(level Level) string
- func SetLevel(module string, level Level)
- func SetSpec(spec string) error
- func ShowCallerInfo(module string, level Level)
- type Level
- type Log
- func (l *Log) Debugf(msg string, args ...interface{})
- func (l *Log) Errorf(msg string, args ...interface{})
- func (l *Log) Fatalf(msg string, args ...interface{})
- func (l *Log) Infof(msg string, args ...interface{})
- func (l *Log) Panicf(msg string, args ...interface{})
- func (l *Log) Warnf(msg string, args ...interface{})
- type Logger
- type LoggerProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAllLevels ¶
GetAllLevels - getting all set log levels
Returns: module names and their associated logging levels
If not set default logging level is info.
func GetSpec ¶ added in v0.1.7
func GetSpec() string
GetSpec returns the log spec which specifies the log level of each individual module. The spec is in the following format:
module1=level1:module2=level2:module3=level3:defaultLevel
Example:
module1=error:module2=debug:module3=warning:info
func HideCallerInfo ¶
HideCallerInfo - Do not show caller info in log lines for given log level and module
Parameters: module is module name level is logging level
note: based on implementation of custom logger, callerinfo info may not be available for custom logging provider
func Initialize ¶
func Initialize(l LoggerProvider)
Initialize sets new custom logging provider which takes over logging operations. It is required to call this function before making any loggings for using custom loggers.
func IsCallerInfoEnabled ¶
IsCallerInfoEnabled - returns if caller info enabled for given log level and module
Parameters: module is module name level is logging level Returns: is caller info enabled for this module and level
note: based on implementation of custom logger, callerinfo info may not be available for custom logging provider
func IsEnabledFor ¶
IsEnabledFor - Check if given log level is enabled for given module
Parameters: module is module name level is logging level Returns: is logging enabled for this module and level
If not set default logging level is info.
func ParseString ¶
ParseString returns string representation of given log level.
Parameters: level is logging level represented as an int Returns: logging level in string representation
func SetLevel ¶
SetLevel - setting log level for given module
Parameters: module is module name level is logging level
If not set default logging level is info.
func SetSpec ¶ added in v0.1.7
SetSpec sets the log levels for individual modules as well as the default log level. The format of the spec is as follows:
module1=level1:module2=level2:module3=level3:defaultLevel
Valid log levels are: critical, error, warning, info, debug
Example:
module1=error:module2=debug:module3=warning:info
func ShowCallerInfo ¶
ShowCallerInfo - Show caller info in log lines for given log level and module.
Parameters: module is module name level is logging level
note: based on implementation of custom logger, callerinfo info may not be available for custom logging provider
Types ¶
type Level ¶
type Level int
Level defines all available log levels for logging messages.
func GetLevel ¶
GetLevel - getting log level for given module
Parameters: module is module name Returns: logging level
If not set default logging level is info.
func ParseLevel ¶
ParseLevel returns the log level from a string representation.
Parameters: level is logging level in string representation Returns: logging level
type Log ¶
type Log struct {
// contains filtered or unexported fields
}
Log is an implementation of Logger interface. It encapsulates default or custom logger to provide module and level based logging.
func New ¶
New creates and returns a Logger implementation based on given module name. note: the underlying logger instance is lazy initialized on first use. To use your own logger implementation provide logger provider in 'Initialize()' before logging any line. If 'Initialize()' is not called before logging any line then default logging implementation will be used.
func (*Log) Fatalf ¶
Fatalf calls Fatalf function of underlying logger should possibly cause system shutdown based on implementation.
type Logger ¶
type Logger interface { // Fatalf is critical fatal logging, should possibly followed by a call to os.Exit(1) Fatalf(msg string, args ...interface{}) // Panicf is critical logging, should possibly followed by panic Panicf(msg string, args ...interface{}) // Debugf is for logging verbose messages Debugf(msg string, args ...interface{}) // Infof for logging general logging messages Infof(msg string, args ...interface{}) // Warnf is for logging messages about possible issues Warnf(msg string, args ...interface{}) // Errorf is for logging errors Errorf(msg string, args ...interface{}) }
Logger - Standard logger interface.
type LoggerProvider ¶
LoggerProvider is a factory for moduled loggers.