Documentation ¶
Overview ¶
Though Go has a logging package in its standard library this package is rather basic. IMHO this is the reason why there are several additional and different logging libraries in the Go community which lead to some irritation when one wants to write an application that ends up with having several different logging frameworks included due to package dependencies.
This package does not address the desire to have one unified logger or at least a unified logging interface. – Let the packages choose their loggers… for good or for bad. However, what I want to be able to do is configure all those loggers in my application in a unified way! At least configure some common things that one often wants to configure:
- Switching loggers for some “topics” on and off
- Setting the log level of loggers
- (may be other things to come in the future)
Note that the first bullet in the list gives the hint that loggers shall be grouped into topics so that configuration becomes simpler.
Index ¶
- func ForTopics(cfg Configurer, do func(current Configurer, path []string))
- func LevelCfgDoc(lvlMap map[string]Level) string
- func ListTopics(cfg Configurer, wr io.Writer, prefix string)
- func SetLevel(cfg Configurer, cfgStr string, lvlMap map[string]Level)
- type Configurer
- type Level
- type LevelMap
- type Topic
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ForTopics ¶
func ForTopics(cfg Configurer, do func(current Configurer, path []string))
func ListTopics ¶
func ListTopics(cfg Configurer, wr io.Writer, prefix string)
func SetLevel ¶
func SetLevel(cfg Configurer, cfgStr string, lvlMap map[string]Level)
Types ¶
type Configurer ¶
type Configurer interface { Name() string Enabled() bool Enable(setEnabled bool) Level() Level SetLevel(l Level) Output() io.Writer SetOutput(wr io.Writer) }
func NewTopic ¶
func NewTopic(represents Configurer, subtopics ...Configurer) Configurer
type Level ¶
type Level = int32
Type Level denotes the importance of a log message. It sets 0 to be the normal log message most commonly identified as Info. More important messages have higher values and less important levels get lower values. These values have to be mapped to specific logging packages by the respective Configurer implementation.
Note that there are no predefined constants for Panic and Fatal as these also imply specific behaviour that gose beyond logging a message. For c4hgol we consider Panic and Fatal to be "a separate story".