| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 | 
							- package main
 
- import (
 
- 	"pbx-api-gin/internal/app"
 
- 	"pbx-api-gin/internal/pkg/configs"
 
- 	"pbx-api-gin/pkg/lfshook"
 
- 	"pbx-api-gin/pkg/utils"
 
- 	"github.com/gin-gonic/gin"
 
- 	"github.com/sirupsen/logrus"
 
- 	"gopkg.in/natefinch/lumberjack.v2"
 
- )
 
- var (
 
- 	gitCommitCode string
 
- 	buildDateTime string
 
- 	goVersion     string
 
- )
 
- func main() {
 
- 	initVersion()
 
- 	// 解析配置文件
 
- 	configs.ConfigPath = "/data/test/configs/config.yaml"
 
- 	configs.DecodeConfig()
 
- 	configs.ConfigGlobal.LogLevel = logrus.InfoLevel
 
- 	gin.SetMode(gin.ReleaseMode)
 
- 	//gin.SetMode(gin.DebugMode)
 
- 	lfshook.NewLogger().Logger.SetReportCaller(true)
 
- 	lfshook.NewLogger().Logger.SetFormatter(&logrus.TextFormatter{
 
- 		ForceQuote:      false,
 
- 		FullTimestamp:   true,
 
- 		TimestampFormat: "2006-01-02 15:04:05",
 
- 	})
 
- 	if configs.ConfigGlobal.LogLevel < logrus.DebugLevel {
 
- 		pathMap := lfshook.LoggerMap{
 
- 			logrus.InfoLevel: &lumberjack.Logger{
 
- 				Filename:   configs.ConfigGlobal.LogInfoPath,
 
- 				MaxSize:    10, // maxSize M
 
- 				MaxBackups: 5,  // keep 5 file
 
- 				MaxAge:     7,  //  7 day
 
- 			},
 
- 			logrus.ErrorLevel: &lumberjack.Logger{
 
- 				Filename:   configs.ConfigGlobal.LogErrorPath,
 
- 				MaxSize:    10, // maxSize M
 
- 				MaxBackups: 5,  // keep 5 file
 
- 				MaxAge:     7,  //  7 day
 
- 			},
 
- 		}
 
- 		lfshook.NewLogger().Logger.Hooks.Add(lfshook.NewHook(
 
- 			pathMap,
 
- 			&logrus.TextFormatter{
 
- 				DisableColors:   true,
 
- 				ForceQuote:      true,
 
- 				TimestampFormat: "2006-01-02 15:04:05",
 
- 			},
 
- 		))
 
- 	}
 
- 	app.StartApp()
 
- 	utils.Exit()
 
- 	//return nil
 
- }
 
- func initVersion() {
 
- 	if gitCommitCode != "" {
 
- 		//构建信息
 
- 		lfshook.NewLogger().Printf("git commit code: %s", gitCommitCode)
 
- 		lfshook.NewLogger().Printf("build date: %s", buildDateTime)
 
- 		lfshook.NewLogger().Printf("go version: %s", goVersion)
 
- 		utils.VersionInstance.BuildDate = buildDateTime
 
- 		utils.VersionInstance.GoVersion = goVersion
 
- 		utils.VersionInstance.GitCommitCode = gitCommitCode
 
- 	}
 
- }
 
 
  |