Browse Source

disable console output xorm log on ssh (#993)

Lunny Xiao 3 years ago
parent
commit
70ae6d197b
1 changed files with 5 additions and 3 deletions
  1. 5 3
      modules/setting/setting.go

+ 5 - 3
modules/setting/setting.go

@@ -958,7 +958,6 @@ func newLogService() {
958 958
 
959 959
 	for i, mode := range LogModes {
960 960
 		sec, err := Cfg.GetSection("log." + mode)
961
-
962 961
 		if err != nil {
963 962
 			sec, _ = Cfg.NewSection("log." + mode)
964 963
 		}
@@ -1025,9 +1024,10 @@ func NewXORMLogService(disableConsole bool) {
1025 1024
 		if disableConsole && mode == "console" {
1026 1025
 			continue
1027 1026
 		}
1027
+
1028 1028
 		sec, err := Cfg.GetSection("log." + mode)
1029 1029
 		if err != nil {
1030
-			log.Fatal(4, "Unknown log mode: %s", mode)
1030
+			sec, _ = Cfg.NewSection("log." + mode)
1031 1031
 		}
1032 1032
 
1033 1033
 		validLevels := []string{"Trace", "Debug", "Info", "Warn", "Error", "Critical"}
@@ -1079,7 +1079,9 @@ func NewXORMLogService(disableConsole bool) {
1079 1079
 		}
1080 1080
 
1081 1081
 		log.NewXORMLogger(Cfg.Section("log").Key("BUFFER_LEN").MustInt64(10000), mode, logConfigs)
1082
-		log.Info("XORM Log Mode: %s(%s)", strings.Title(mode), levelName)
1082
+		if !disableConsole {
1083
+			log.Info("XORM Log Mode: %s(%s)", strings.Title(mode), levelName)
1084
+		}
1083 1085
 
1084 1086
 		var lvl core.LogLevel
1085 1087
 		switch levelName {