forked from xlab/suplog
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdefault_test.go
69 lines (55 loc) · 1.84 KB
/
default_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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package suplog_test
import (
"os"
"testing"
"time"
"github.com/pkg/errors"
. "github.com/InjectiveLabs/suplog"
bugsnagHook "github.com/InjectiveLabs/suplog/hooks/bugsnag"
debugHook "github.com/InjectiveLabs/suplog/hooks/debug"
"github.com/InjectiveLabs/suplog/wrapped-test"
)
func TestAll(t *testing.T) {
Print("This is an example basic message")
Success("This is an example success message")
Warning("This is an example warning message")
Error("This is an example error message")
Debug("This is an example debug message")
NewLogger(os.Stderr, nil, debugHook.NewHook(DefaultLogger, nil)).
Debug("Debug message from non-default suplogger")
// Test logger wrapping with StackTraceOffset
logWithOffset := NewLogger(os.Stderr, nil,
debugHook.NewHook(DefaultLogger, &debugHook.HookOptions{
StackTraceOffset: 1,
}),
bugsnagHook.NewHook(DefaultLogger, &bugsnagHook.HookOptions{
StackTraceOffset: 1,
}))
logWithOffset.(LoggerConfigurator).SetStackTraceOffset(1)
wrapped.NewTestWrapper(logWithOffset).ErrorText("This is an example error message from wrapped logger")
errWrapped := errors.New("This is an example wrapped error message from wrapped logger")
wrapped.NewTestWrapper(logWithOffset).ErrorWrapped(errWrapped)
wrapped.NewTestWrapper(logWithOffset).DebugText("This is an example debug message from wrapped logger")
time.Sleep(time.Second)
}
func ExamplePrint() {
Print("Hello world!")
}
func ExamplePrintf() {
Printf("Hello world! My name is %s.", "Loggy")
}
func ExampleNotification() {
Notification("Hello world! My name is %s.", "Loggy")
}
func ExampleSuccess() {
Success("Hello world! My name is %s.", "Loggy")
}
func ExampleWarning() {
Warning("Hello world! My name is %s.", "Loggy")
}
func ExampleError() {
Error("Hello world! My name is %s.", "Loggy")
}
func ExampleDebug() {
Debug("Hello world! My name is %s.", "Loggy")
}