-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_test.go
More file actions
55 lines (33 loc) · 1.14 KB
/
example_test.go
File metadata and controls
55 lines (33 loc) · 1.14 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
package slog
import (
"fmt"
)
func ExampleWrap(){
var myCutomFunction SLogger = func(data ...interface{}) interface{} { fmt.Print(data...); return nil }
var myCutomLevel = Level{"myCutomLevel", 5}
Wrap(&myCutomFunction, myCutomLevel, false)
SetLevel(LvlAll)
myCutomFunction("some data for print")
// Output: some data for print
}
func ExampleBind(){
var myStdBindFun SLogger = func(data ...interface{}) interface{} { fmt.Println(data...); return nil }
var myCustomDebugFunc SLogger
var myCustomDebugLevel = Level{"myCustomDebugLevel", 5}
Bind(&myCustomDebugFunc, myStdBindFun, myCustomDebugLevel, false)
var myCustomNoticeFunc SLogger
var myCustomNoticeLevel = Level{"myCustomNoticeLevel", 15}
Bind(&myCustomNoticeFunc, myStdBindFun, myCustomNoticeLevel, false)
SetLevel(LvlAll)
myCustomDebugFunc("some debug data")
myCustomDebugFunc("some info data")
// Output:
// some debug data
// some info data
}
func ExampleFormattedLog(){
SetLevel(LvlInfo)
SetFormat(FormatDefault)
Infof("One string: %s, two string: %s, three int: %d", "1str", "2str", 3)
// Output: One string: 1str, two string: 2str, three int: 3
}