qinglong-go/main.go

44 lines
1.1 KiB
Go
Raw Normal View History

2022-11-16 10:20:07 +00:00
package main
import (
2022-11-20 14:11:47 +00:00
nested "github.com/Lyrics-you/sail-logrus-formatter/sailor"
2022-11-16 10:20:07 +00:00
"github.com/huoxue1/qinglong-go/controller"
2022-11-26 02:31:26 +00:00
"github.com/huoxue1/qinglong-go/service"
2022-11-20 14:11:47 +00:00
rotates "github.com/lestrrat-go/file-rotatelogs"
log "github.com/sirupsen/logrus"
"io"
"os"
"path"
"time"
2022-11-16 10:20:07 +00:00
)
2022-11-20 14:11:47 +00:00
func init() {
2022-11-26 02:31:26 +00:00
w, err := rotates.New(path.Join("data", "log", "qinglong-go", "%Y-%m-%d.log"), rotates.WithRotationTime(time.Hour*24))
2022-11-20 14:11:47 +00:00
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,
})
}
2022-11-16 10:20:07 +00:00
func main() {
2022-11-26 02:31:26 +00:00
service.AppInit()
2022-11-16 10:20:07 +00:00
engine := controller.Router()
_ = engine.Run(":8080")
}