func newDefaultLogOptions() defaultLogOptions {
return defaultLogOptions{
- levelName: LogLevel,
+ levelName: LogLevel.String(),
flags: "stdflags",
filename: filepath.Join(LogRootPath, "gitea.log"),
bufferLength: 10000,
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 {
}
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
}
// Log settings
- LogLevel string
+ LogLevel log.Level
StacktraceLogLevel string
LogRootPath string
DisableRouterLog bool
}
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)
cfg.Section("session").Key("PROVIDER").SetValue("file")
cfg.Section("log").Key("MODE").SetValue("console")
- cfg.Section("log").Key("LEVEL").SetValue(setting.LogLevel)
+ cfg.Section("log").Key("LEVEL").SetValue(setting.LogLevel.String())
cfg.Section("log").Key("ROOT_PATH").SetValue(form.LogRootPath)
cfg.Section("log").Key("ROUTER").SetValue("console")