forked from go-aah/aah
-
Notifications
You must be signed in to change notification settings - Fork 0
/
log_test.go
55 lines (44 loc) · 1.15 KB
/
log_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
// Copyright (c) Jeevanandam M. (https://github.com/jeevatkm)
// go-aah/aah source code and usage is governed by a MIT style
// license that can be found in the LICENSE file.
package aah
import (
"path/filepath"
"testing"
"aahframework.org/config.v0"
"aahframework.org/essentials.v0"
"aahframework.org/log.v0"
"aahframework.org/test.v0/assert"
)
func TestLogInitRelativeFilePath(t *testing.T) {
logPath := filepath.Join(testdataBaseDir(), "sample-test-app.log")
defer ess.DeleteFiles(logPath)
// Relative path file
a := newApp()
cfg, _ := config.ParseString(`log {
receiver = "file"
file = "sample-test-app.log"
}`)
a.cfg = cfg
err := a.initLog()
assert.Nil(t, err)
a.AddLoggerHook("myapphook", func(e log.Entry) {
t.Logf("%v", e)
})
}
func TestLogInitNoFilePath(t *testing.T) {
// No file input - auto location
logPath := filepath.Join(testdataBaseDir(), "wepapp1.log")
defer ess.DeleteFiles(logPath)
// Relative path file
a := newApp()
cfg, _ := config.ParseString(`log {
receiver = "file"
}`)
a.cfg = cfg
err := a.initLog()
assert.Nil(t, err)
a.AddLoggerHook("myapphook", func(e log.Entry) {
t.Logf("%v", e)
})
}