adjust log directory

This commit is contained in:
nuknal
2024-07-18 10:47:24 +08:00
parent 0d1fea2f5d
commit 688f709b39
5 changed files with 26 additions and 9 deletions

View File

@@ -48,8 +48,6 @@ func init() {
ForceColors: false,
DisableColors: true,
}
configureLogger(logrus.StandardLogger(), "log/SJY01-imgproc.log", logrus.DebugLevel)
}
func NewLogger(logfile string) *logrus.Logger {
@@ -65,7 +63,7 @@ func configureLogger(logger *logrus.Logger, logfile string, level logrus.Level)
writer, _ := rotatelogs.New(
logfile+".%Y%m%d",
rotatelogs.WithLinkName(logfile),
rotatelogs.WithMaxAge(time.Duration(30*24)*time.Hour),
rotatelogs.WithMaxAge(time.Duration(7*24)*time.Hour),
rotatelogs.WithRotationTime(time.Duration(24)*time.Hour),
)

View File

@@ -27,7 +27,12 @@ var procCmd = &cobra.Command{
Long: `process images`,
Run: func(cmd *cobra.Command, args []string) {
config.GViper = config.InitViper(configFile)
logrus.SetLevel(config.GCONFIG.LogLevel)
os.MkdirAll(config.GCONFIG.Log.LogDir, 0755)
configureLogger(logrus.StandardLogger(),
filepath.Join(config.GCONFIG.Log.LogDir, "imgproc.log"),
config.GCONFIG.Log.LogLevel)
logrus.SetLevel(config.GCONFIG.Log.LogLevel)
reg := producer.NewRegistrator(producer.DownSampled)
reg.Params = initParams()
@@ -35,7 +40,7 @@ var procCmd = &cobra.Command{
if err := reg.LoadAuxData(); err != nil {
logrus.Fatal(err)
}
reg.AuxPrint()
// reg.AuxPrint()
if err := reg.LoadMssRaw(); err != nil {
logrus.Fatal(err)