-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.go
52 lines (45 loc) · 994 Bytes
/
main.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
package main
import (
"bytes"
"flag"
"fmt"
"os"
"github.com/gothyra/thyra/server"
log "gopkg.in/inconshreveable/log15.v2"
"gopkg.in/inconshreveable/log15.v2/stack"
)
func customFormat() log.Format {
return log.FormatFunc(func(r *log.Record) []byte {
var color = 0
switch r.Lvl {
case log.LvlCrit:
color = 35
case log.LvlError:
color = 31
case log.LvlWarn:
color = 33
case log.LvlInfo:
color = 32
case log.LvlDebug:
color = 36
}
b := &bytes.Buffer{}
call := stack.Call(r.CallPC[0])
fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m [%s %s:%d] %s\n", color, r.Lvl, r.Time.Format("2006-01-02|15:04:05.000"), call, call, r.Msg)
return b.Bytes()
})
}
func init() {
h := log.StreamHandler(os.Stdout, customFormat())
log.Root().SetHandler(h)
}
var port = flag.Int("port", 3030, "Port to listen on incoming connections")
func main() {
flag.Parse()
s, err := server.NewServer(*port)
if err != nil {
log.Error(err.Error())
os.Exit(1)
}
s.StartServer()
}