Skip to content

Commit

Permalink
[doc][log] Add suervey for seelog #26
Browse files Browse the repository at this point in the history
- detail xml config, filter by level, file, function (require calling runtime,
expensive)
- many small files, some just have one interface (quite java style ...)
- created back in 2011 ...
  • Loading branch information
at15 committed Dec 21, 2017
1 parent 7026e06 commit 1c20051
Showing 1 changed file with 53 additions and 1 deletion.
54 changes: 53 additions & 1 deletion log2/doc/seelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,56 @@

https://github.com/cihub/seelog

has a java style xml config ...
it has very detailed config (like log4j), also allow control logging behaviour of library.
besides level, it also support file and function pattern.

````xml
<seelog minlevel="info">
<exceptions>
<exception filepattern="test*" minlevel="error"/>
<exception funcpattern="*test*" filepattern="tests.go" levels="off"/>
<exception funcpattern="*perfCritical" minlevel="critical"/>
</exceptions>
</seelog>
````

- patterns are matched using string comparison (not using regexp, custom recursive implementation)

````go
// logConfig stores logging configuration. Contains messages dispatcher, allowed log level rules
// (general constraints and exceptions)
type logConfig struct {
Constraints logLevelConstraints // General log level rules (>min and <max, or set of allowed levels)
Exceptions []*LogLevelException // Exceptions to general rules for specific files or funcs
RootDispatcher dispatcherInterface // Root of output tree
}

// LogLevelException represents an exceptional case used when you need some specific files or funcs to
// override general constraints and to use their own.
type LogLevelException struct {
funcPatternParts []string
filePatternParts []string

funcPattern string
filePattern string

constraints logLevelConstraints
}

// stringMatchesPattern check whether testString matches pattern with asterisks.
// Standard regexp functionality is not used here because of performance issues.
func stringMatchesPattern(patternparts []string, testString string) bool {
// ...
}
````

````go
// innerLoggerInterface is an internal logging interface
type innerLoggerInterface interface {
innerLog(level LogLevel, context LogContextInterface, message fmt.Stringer)
Flush()
}

````

- log -> dispatcher -> write to output

0 comments on commit 1c20051

Please sign in to comment.