Browse Source

fix panic when push but the only log mode console is disabled by serv and update commands (#1007)

Lunny Xiao 2 years ago
parent
commit
d6748284bd
2 changed files with 11 additions and 0 deletions
  1. 7 0
      modules/log/xorm.go
  2. 4 0
      modules/setting/setting.go

+ 7 - 0
modules/log/xorm.go

@@ -22,6 +22,13 @@ var (
22 22
 	XORMLogger *XORMLogBridge
23 23
 )
24 24
 
25
+// DiscardXORMLogger inits a blank logger for xorm
26
+func DiscardXORMLogger() {
27
+	XORMLogger = &XORMLogBridge{
28
+		showSQL: false,
29
+	}
30
+}
31
+
25 32
 // NewXORMLogger generate logger for xorm FIXME: configable
26 33
 func NewXORMLogger(bufferlen int64, mode, config string) {
27 34
 	logger := newLogger(bufferlen)

+ 4 - 0
modules/setting/setting.go

@@ -1096,6 +1096,10 @@ func NewXORMLogService(disableConsole bool) {
1096 1096
 		}
1097 1097
 		log.XORMLogger.SetLevel(lvl)
1098 1098
 	}
1099
+
1100
+	if len(logConfigs) == 0 {
1101
+		log.DiscardXORMLogger()
1102
+	}
1099 1103
 }
1100 1104
 
1101 1105
 func newCacheService() {