fix(be):使用next-terminal 自定义的日志

This commit is contained in:
teaser
2021-03-19 22:58:47 +08:00
committed by dushixiang
parent e957545f1d
commit 0e4a5f97d9
19 changed files with 322 additions and 184 deletions

22
main.go
View File

@ -1,19 +1,14 @@
package main
import (
"bytes"
"fmt"
"io"
"os"
"next-terminal/server/api"
"next-terminal/server/config"
"next-terminal/server/global"
nested "github.com/antonfisher/nested-logrus-formatter"
"github.com/labstack/gommon/log"
"github.com/robfig/cron/v3"
"github.com/sirupsen/logrus"
)
const Version = "v0.3.4"
@ -35,23 +30,6 @@ func Run() error {
\____|__ /\___ >__/\_ \ |__| |____| \___ >__| |__|_| /__|___| (____ /____/
\/ \/ \/ \/ \/ \/ \/ ` + Version + "\n\n")
var err error
//logrus.SetReportCaller(true)
logrus.SetLevel(logrus.DebugLevel)
logrus.SetFormatter(&nested.Formatter{
HideKeys: true,
FieldsOrder: []string{"component", "category"},
})
writer1 := &bytes.Buffer{}
writer2 := os.Stdout
writer3, err := os.OpenFile("log/next-terminal.log", os.O_WRONLY|os.O_CREATE, 0755)
if err != nil {
log.Fatalf("create file log.txt failed: %v", err)
}
logrus.SetOutput(io.MultiWriter(writer1, writer2, writer3))
global.Config = config.SetupConfig()
global.Store = global.NewStore()