-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.go
56 lines (47 loc) · 1.21 KB
/
init.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
package utils
import (
"fmt"
"github.com/bradfitz/gomemcache/memcache"
"github.com/cihub/seelog"
"github.com/gorilla/sessions"
"github.com/hulucat/conf"
"os"
)
var logger seelog.LoggerInterface
func Debug(content string) {
logger.Debug(content)
}
func Info(content string) {
logger.Debug(content)
}
func Debugf(format string, args ...interface{}) {
logger.Debugf(format, args...)
}
func Errorf(format string, args ...interface{}) {
logger.Errorf(format, args...)
}
func Infof(format string, args ...interface{}) {
logger.Infof(format, args...)
}
func Warnf(format string, args ...interface{}) {
logger.Warnf(format, args...)
}
func init() {
appConf := `
<seelog type="sync">
<outputs>
<rollingfile type="date" filename="./logs/` + os.Args[0] + `.log" datepattern="20060102" formatid="main"/>
</outputs>
<formats>
<format id="main" format="%Date %Time [%LEV] | %Msg%n"/>
</formats>
</seelog>`
var err error
logger, err = seelog.LoggerFromConfigAsBytes([]byte(appConf))
if err != nil {
fmt.Errorf("Error loading log configuration: %s \n", err.Error())
panic(err)
}
Mclient = memcache.New(conf.Get("memcached"))
sessionStore = sessions.NewCookieStore([]byte(conf.Get("cookie_secret")))
}