summaryrefslogtreecommitdiffstats
path: root/modules/setting
diff options
context:
space:
mode:
Diffstat (limited to 'modules/setting')
-rw-r--r--modules/setting/log.go11
-rw-r--r--modules/setting/setting.go4
2 files changed, 7 insertions, 8 deletions
diff --git a/modules/setting/log.go b/modules/setting/log.go
index 9bbeee27a2..44017b1138 100644
--- a/modules/setting/log.go
+++ b/modules/setting/log.go
@@ -94,7 +94,7 @@ type defaultLogOptions struct {
func newDefaultLogOptions() defaultLogOptions {
return defaultLogOptions{
- levelName: LogLevel,
+ levelName: LogLevel.String(),
flags: "stdflags",
filename: filepath.Join(LogRootPath, "gitea.log"),
bufferLength: 10000,
@@ -115,9 +115,9 @@ type LogDescription struct {
SubLogDescriptions []SubLogDescription
}
-func getLogLevel(section *ini.Section, key string, defaultValue string) string {
- value := section.Key(key).MustString("info")
- return log.FromString(value).String()
+func getLogLevel(section *ini.Section, key string, defaultValue log.Level) log.Level {
+ value := section.Key(key).MustString(defaultValue.String())
+ return log.FromString(value)
}
func getStacktraceLogLevel(section *ini.Section, key string, defaultValue string) string {
@@ -126,8 +126,7 @@ func getStacktraceLogLevel(section *ini.Section, key string, defaultValue string
}
func generateLogConfig(sec *ini.Section, name string, defaults defaultLogOptions) (mode, jsonConfig, levelName string) {
- levelName = getLogLevel(sec, "LEVEL", LogLevel)
- level := log.FromString(levelName)
+ level := getLogLevel(sec, "LEVEL", LogLevel)
stacktraceLevelName := getStacktraceLogLevel(sec, "STACKTRACE_LEVEL", StacktraceLogLevel)
stacktraceLevel := log.FromString(stacktraceLevelName)
mode = name
diff --git a/modules/setting/setting.go b/modules/setting/setting.go
index 9d27a5d743..6a9868713f 100644
--- a/modules/setting/setting.go
+++ b/modules/setting/setting.go
@@ -304,7 +304,7 @@ var (
}
// Log settings
- LogLevel string
+ LogLevel log.Level
StacktraceLogLevel string
LogRootPath string
DisableRouterLog bool
@@ -553,7 +553,7 @@ func NewContext() {
}
homeDir = strings.ReplaceAll(homeDir, "\\", "/")
- LogLevel = getLogLevel(Cfg.Section("log"), "LEVEL", "Info")
+ LogLevel = getLogLevel(Cfg.Section("log"), "LEVEL", log.INFO)
StacktraceLogLevel = getStacktraceLogLevel(Cfg.Section("log"), "STACKTRACE_LEVEL", "None")
LogRootPath = Cfg.Section("log").Key("ROOT_PATH").MustString(path.Join(AppWorkPath, "log"))
forcePathSeparator(LogRootPath)