-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
57 lines (50 loc) · 1.33 KB
/
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
53
54
55
56
57
package main
import (
"flag"
"fmt"
"github.com/seknox/trasadbproxy/proxy"
logger "github.com/sirupsen/logrus"
"os"
"path/filepath"
"runtime"
)
func main() {
logLevel := flag.String("l", "trace", "Set log level")
logOutputToFile := flag.Bool("f", false, "Write to file")
flag.Parse()
level, err := logger.ParseLevel(*logLevel)
if err != nil {
logger.Error(err)
}
//logger.Trace(level, false)
if *logOutputToFile {
f, err := os.OpenFile("/var/log/trasadbproxy.log", os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644)
if err != nil {
panic(err)
}
logger.SetOutput(f)
} else {
logger.SetOutput(os.Stdout)
}
logger.SetLevel(level)
logger.SetReportCaller(true)
logger.SetFormatter(&logger.TextFormatter{
ForceColors: false,
DisableColors: false,
//ForceQuote: false,
EnvironmentOverrideColors: false,
DisableTimestamp: false,
FullTimestamp: true,
TimestampFormat: "",
DisableSorting: true,
SortingFunc: nil,
DisableLevelTruncation: false,
//PadLevelText: false,
QuoteEmptyFields: false,
FieldMap: nil,
CallerPrettyfier: func(frame *runtime.Frame) (function string, file string) {
return filepath.Base(frame.Function), fmt.Sprintf(`%s:%d`, filepath.Base(frame.File), frame.Line)
},
})
proxy.StartListner()
}