-
Notifications
You must be signed in to change notification settings - Fork 1
/
provider_examples_test.go
42 lines (33 loc) · 1.3 KB
/
provider_examples_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package native_test
import (
"os"
"github.com/echocat/slf4g/native/location"
"github.com/echocat/slf4g/level"
"github.com/echocat/slf4g/native"
"github.com/echocat/slf4g/native/color"
"github.com/echocat/slf4g/native/consumer"
"github.com/echocat/slf4g/native/formatter"
"github.com/echocat/slf4g/native/interceptor"
)
func Example_customization() {
// Set the log level globally to Debug
native.DefaultProvider.Level = level.Debug
// Configure the text formatter to be used.
formatter.Default = formatter.NewText(func(v *formatter.Text) {
// ... which never colorizes something.
v.ColorMode = color.ModeNever
// ... and just prints hours, minutes and seconds
v.TimeLayout = "150405"
})
// Configures a writer consumer that writes everything to stdout (instead
// of stderr; which is the default)
consumer.Default = consumer.NewWriter(os.Stdout)
// Add an interceptor which will exit the application if someone logs
// something on level.Fatal or above. This is disabled by default.
interceptor.Default.Add(interceptor.NewFatal())
// Change the location.Discovery to log everything detail instead of
// simplified (which is the default).
location.DefaultDiscovery = location.NewCallerDiscovery(func(t *location.CallerDiscovery) {
t.ReportingDetail = location.CallerReportingDetailDetailed
})
}