Skip to content

Commit

Permalink
Merge pull request #18 from PKUHPC/loglevel_and_encode
Browse files Browse the repository at this point in the history
1. 增加日志打印及日志等级可配; 2. 修复数据库编码为latin1时提交中文名作业失败的问题
  • Loading branch information
Miracle575 authored Sep 11, 2024
2 parents 77fd58c + 7d0b076 commit 8be28a0
Show file tree
Hide file tree
Showing 9 changed files with 245 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
gen
gen
.idea
11 changes: 10 additions & 1 deletion caller/caller.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,16 @@ func initLogger() {
// 设置日志输出格式为JSON
Logger.SetFormatter(&LogFormatter{})
// 设置日志级别为Info
Logger.SetLevel(logrus.InfoLevel)
switch ConfigValue.LogConfig.Level {
case "info":
Logger.SetLevel(logrus.InfoLevel)
case "debug":
Logger.SetLevel(logrus.DebugLevel)
case "trace":
Logger.SetLevel(logrus.TraceLevel)
default:
Logger.SetLevel(logrus.InfoLevel)
}

// 创建一个 lumberjack.Logger,用于日志轮转配置
logFile := &lumberjack.Logger{
Expand Down
3 changes: 3 additions & 0 deletions config/config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
log:
level: "info"

# slurm 数据库配置
mysql:
host: 127.0.0.1
Expand Down
Loading

0 comments on commit 8be28a0

Please sign in to comment.