forked from huoxue1/qinglong-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
54 lines (50 loc) · 1.35 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
package main
import (
"flag"
nested "github.com/Lyrics-you/sail-logrus-formatter/sailor"
"github.com/huoxue1/qinglong-go/controller"
"github.com/huoxue1/qinglong-go/service"
"github.com/huoxue1/qinglong-go/service/config"
env_check "github.com/huoxue1/qinglong-go/utils/env-check"
rotates "github.com/lestrrat-go/file-rotatelogs"
log "github.com/sirupsen/logrus"
"io"
"os"
"path"
"time"
)
var (
address string
)
func init() {
w, err := rotates.New(path.Join("data", "log", "qinglong-go", "%Y-%m-%d.log"), rotates.WithRotationTime(time.Hour*24))
if err != nil {
log.Errorf("rotates init err: %v", err)
panic(err)
}
log.SetOutput(io.MultiWriter(w, os.Stdout))
log.SetFormatter(&nested.Formatter{
FieldsOrder: nil,
TimeStampFormat: "2006-01-02 15:04:05",
CharStampFormat: "",
HideKeys: false,
Position: true,
Colors: true,
FieldsColors: true,
FieldsSpace: true,
ShowFullLevel: false,
LowerCaseLevel: true,
TrimMessages: true,
CallerFirst: false,
CustomCallerFormatter: nil,
})
flag.StringVar(&address, "add", "0.0.0.0:5700", "the ql listen address!")
flag.Parse()
config.SetAddress(address)
}
func main() {
env_check.CheckStatic()
service.AppInit()
engine := controller.Router()
_ = engine.Run(address)
}