summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorPiotr Orzechowski <tech@orzechowski.hub.pl>2017-12-01 08:41:27 +0100
committerLunny Xiao <xiaolunwen@gmail.com>2017-12-01 15:41:27 +0800
commit57edc3155fa910729bee912d637ad2fd77cb2bba (patch)
tree66b88519aec0fefc6db6f990a17856a23de50456 /modules
parent9a8805d785597a04ad03da4834a0c5f033c4a83a (diff)
downloadgitea-57edc3155fa910729bee912d637ad2fd77cb2bba.tar.gz
gitea-57edc3155fa910729bee912d637ad2fd77cb2bba.zip
Default log level to Info without hardcoding it in installer (#3041)
Diffstat (limited to 'modules')
-rw-r--r--modules/setting/setting.go17
1 files changed, 9 insertions, 8 deletions
diff --git a/modules/setting/setting.go b/modules/setting/setting.go
index 9bb7da4456..db6f749c06 100644
--- a/modules/setting/setting.go
+++ b/modules/setting/setting.go
@@ -331,6 +331,7 @@ var (
LibravatarService *libravatar.Libravatar
// Log settings
+ LogLevel string
LogRootPath string
LogModes []string
LogConfigs []string
@@ -659,6 +660,7 @@ func NewContext() {
}
homeDir = strings.Replace(homeDir, "\\", "/", -1)
+ LogLevel = getLogLevel("log", "LEVEL", "Info")
LogRootPath = Cfg.Section("log").Key("ROOT_PATH").MustString(path.Join(AppWorkPath, "log"))
forcePathSeparator(LogRootPath)
@@ -1192,6 +1194,11 @@ var logLevels = map[string]string{
"Critical": "5",
}
+func getLogLevel(section string, key string, defaultValue string) string {
+ validLevels := []string{"Trace", "Debug", "Info", "Warn", "Error", "Critical"}
+ return Cfg.Section(section).Key(key).In(defaultValue, validLevels)
+}
+
func newLogService() {
log.Info("Gitea v%s%s", AppVer, AppBuiltWith)
@@ -1216,11 +1223,8 @@ func newLogService() {
sec, _ = Cfg.NewSection("log." + mode)
}
- validLevels := []string{"Trace", "Debug", "Info", "Warn", "Error", "Critical"}
// Log level.
- levelName := Cfg.Section("log."+mode).Key("LEVEL").In(
- Cfg.Section("log").Key("LEVEL").In("Trace", validLevels),
- validLevels)
+ levelName := getLogLevel("log."+mode, "LEVEL", LogLevel)
level, ok := logLevels[levelName]
if !ok {
log.Fatal(4, "Unknown log level: %s", levelName)
@@ -1284,11 +1288,8 @@ func NewXORMLogService(disableConsole bool) {
sec, _ = Cfg.NewSection("log." + mode)
}
- validLevels := []string{"Trace", "Debug", "Info", "Warn", "Error", "Critical"}
// Log level.
- levelName := Cfg.Section("log."+mode).Key("LEVEL").In(
- Cfg.Section("log").Key("LEVEL").In("Trace", validLevels),
- validLevels)
+ levelName := getLogLevel("log."+mode, "LEVEL", LogLevel)
level, ok := logLevels[levelName]
if !ok {
log.Fatal(4, "Unknown log level: %s", levelName)