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 ¶
- Constants
- func ForLogs(cfg Configurer, do func(current Configurer, path []string))
- func LevelCfgDoc(levelMap map[string]Level) string
- func ListAllLogs(cfg Configurer, wr io.Writer, prefix string)
- func ListLogs(cfg Configurer, wr io.Writer, prefix string)
- func SetLevel(cfg Configurer, cfgStr string, lvlMap map[string]Level)
- func ShowSource(cfg Configurer, on, filepath bool) bool
- type Configurer
- type Group
- type Level
- type LevelMap
- type ShowSrcConfigurer
- type Topic
Constants ¶
const ( DefaultFlagLevel = "log" DefaultFlagList = "logs" )
const PathSep byte = '/'
Variables ¶
This section is empty.
Functions ¶
func ForLogs ¶ added in v0.10.0
func ForLogs(cfg Configurer, do func(current Configurer, path []string))
func ListAllLogs ¶ added in v0.10.1
func ListAllLogs(cfg Configurer, wr io.Writer, prefix string)
func ListLogs ¶ added in v0.10.0
func ListLogs(cfg Configurer, wr io.Writer, prefix string)
func SetLevel ¶
func SetLevel(cfg Configurer, cfgStr string, lvlMap map[string]Level)
TODO describe howto use cfgStr: [[~]log:]level[+(s|S)] (,-sep list of them)
func ShowSource ¶ added in v0.10.3
func ShowSource(cfg Configurer, on, filepath bool) bool
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 Config ¶ added in v0.10.1
func Config(parent Configurer, sub ...Configurer) Configurer
type Group ¶ added in v0.10.0
type Group struct {
// contains filtered or unexported fields
}
func NewGroup ¶ added in v0.10.0
func NewGroup(title string, subtopics ...Configurer) *Group
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".
type LevelMap ¶
type ShowSrcConfigurer ¶ added in v0.10.0
type ShowSrcConfigurer interface { Configurer ShowSrc(on, filepath bool) }
type Topic ¶
type Topic struct {
// contains filtered or unexported fields
}
func NewTopic ¶
func NewTopic(represents Configurer, subtopics ...Configurer) *Topic
func (*Topic) Level ¶
Level returns the most irrelevant level of all Configurers in this topic. If the topic has no Configurer Info is always returned.