package main

import (
	_ "boss/internal/models"
	_ "boss/internal/routers"

	"github.com/beego/beego/v2/core/logs"
	"github.com/beego/beego/v2/server/web"
	_ "github.com/beego/beego/v2/server/web/session/redis"
	_ "github.com/go-sql-driver/mysql"
)

func main() {
	RegisterLogs()
	web.Run()
}

// RegisterLogs 注册日志信息
func RegisterLogs() {
	config := `{
		"filename": "./logs/app.log",
		"maxlines": 0,
		"maxsize": 0,
		"daily": true,
		"maxdays": 7,
		"perm": "0644",
		"separate": ""
	}`
	_ = logs.SetLogger(logs.AdapterFile, config)
	logs.SetLevel(logs.LevelWarning)
	f := &logs.PatternLogFormatter{
		Pattern:    "%F:%n|%w%t>> %m",
		WhenFormat: "2006-01-02",
	}
	logs.RegisterFormatter("pattern", f)
	_ = logs.SetGlobalFormatter("pattern")
	logs.Async()
}
