mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-08-29 05:33:53 +00:00
feat(logger): rename settings for consistency and remove obsolete settings (#8667)
- [x] rename logger settings: `logger.<name>.MODE` -> `LOGGER_<NAME>_MODE` - [x] dropped legacy logger settings - [ ] create a docs PR to update documentation I used Github Copilot for some auto completion of code. ## Checklist The [contributor guide](https://forgejo.org/docs/next/contributor/) contains information that will be helpful to first time contributors. There also are a few [conditions for merging Pull Requests in Forgejo repositories](https://codeberg.org/forgejo/governance/src/branch/main/PullRequestsAgreement.md). You are also welcome to join the [Forgejo development chatroom](https://matrix.to/#/#forgejo-development:matrix.org). ### Tests - I added test coverage for Go changes... - [x] in their respective `*_test.go` for unit tests. - [ ] in the `tests/integration` directory if it involves interactions with a live Forgejo server. - I added test coverage for JavaScript changes... - [ ] in `web_src/js/*.test.js` if it can be unit tested. - [ ] in `tests/e2e/*.test.e2e.js` if it requires interactions with a live Forgejo server (see also the [developer guide for JavaScript testing](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/tests/e2e/README.md#end-to-end-tests)). ### Documentation - [x] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change. - [ ] I did not document these changes and I do not expect someone else to do it. ### Release notes - [ ] I do not want this change to show in the release notes. - [x] I want the title to show in the release notes with a link to this pull request. - [ ] I want the content of the `release-notes/<pull request number>.md` to be be used for the release notes instead of the title. <!--start release-notes-assistant--> ## Release notes <!--URL:https://codeberg.org/forgejo/forgejo--> - Breaking features - [PR](https://codeberg.org/forgejo/forgejo/pulls/8667): <!--number 8667 --><!--line 0 --><!--description ZmVhdChsb2dnZXIpOiByZW5hbWUgc2V0dGluZ3MgZm9yIGNvbnNpc3RlbmN5IGFuZCByZW1vdmUgb2Jzb2xldGUgc2V0dGluZ3M=-->feat(logger): rename settings for consistency and remove obsolete settings<!--description--> <!--end release-notes-assistant--> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8667 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Co-authored-by: Michael Kriese <michael.kriese@visualon.de> Co-committed-by: Michael Kriese <michael.kriese@visualon.de>
This commit is contained in:
parent
fb57260056
commit
f185a4ce67
7 changed files with 100 additions and 36 deletions
|
@ -56,41 +56,73 @@ func loadLogGlobalFrom(rootCfg ConfigProvider) {
|
|||
func prepareLoggerConfig(rootCfg ConfigProvider) {
|
||||
sec := rootCfg.Section("log")
|
||||
|
||||
if !sec.HasKey("logger.default.MODE") {
|
||||
sec.Key("logger.default.MODE").MustString(",")
|
||||
// Priority: `LOGGER_DEFAULT_MODE` -> `logger.default.MODE`
|
||||
deprecatedSettingWarning(rootCfg, "log", "logger.default.MODE", "log", "LOGGER_DEFAULT_MODE")
|
||||
hasNoValue := !sec.HasKey("LOGGER_DEFAULT_MODE")
|
||||
if hasNoValue && sec.HasKey("logger.default.MODE") {
|
||||
sec.Key("LOGGER_DEFAULT_MODE").SetValue(sec.Key("logger.default.MODE").String())
|
||||
hasNoValue = false
|
||||
}
|
||||
if hasNoValue {
|
||||
sec.Key("LOGGER_DEFAULT_MODE").SetValue(",") // use default logger
|
||||
}
|
||||
|
||||
deprecatedSetting(rootCfg, "log", "ACCESS", "log", "logger.access.MODE", "1.21")
|
||||
deprecatedSetting(rootCfg, "log", "ENABLE_ACCESS_LOG", "log", "logger.access.MODE", "1.21")
|
||||
if val := sec.Key("ACCESS").String(); val != "" {
|
||||
sec.Key("logger.access.MODE").MustString(val)
|
||||
// Priority: `ENABLE_ACCESS_LOG` -> `LOGGER_ACCESS_MODE` -> `logger.access.MODE` -> `ACCESS`
|
||||
deprecatedSettingWarning(rootCfg, "log", "ACCESS", "log", "LOGGER_ACCESS_MODE")
|
||||
deprecatedSettingWarning(rootCfg, "log", "ENABLE_ACCESS_LOG", "log", "LOGGER_ACCESS_MODE")
|
||||
deprecatedSettingWarning(rootCfg, "log", "logger.access.MODE", "log", "LOGGER_ACCESS_MODE")
|
||||
hasNoValue = !sec.HasKey("LOGGER_ACCESS_MODE")
|
||||
if hasNoValue && sec.HasKey("logger.access.MODE") {
|
||||
sec.Key("LOGGER_ACCESS_MODE").SetValue(sec.Key("logger.access.MODE").String())
|
||||
hasNoValue = false
|
||||
}
|
||||
if val := sec.Key("ACCESS").String(); hasNoValue && val != "" {
|
||||
sec.Key("LOGGER_ACCESS_MODE").SetValue(val)
|
||||
}
|
||||
if sec.HasKey("ENABLE_ACCESS_LOG") && !sec.Key("ENABLE_ACCESS_LOG").MustBool() {
|
||||
sec.Key("logger.access.MODE").SetValue("")
|
||||
sec.Key("LOGGER_ACCESS_MODE").SetValue("")
|
||||
}
|
||||
|
||||
deprecatedSetting(rootCfg, "log", "ROUTER", "log", "logger.router.MODE", "1.21")
|
||||
deprecatedSetting(rootCfg, "log", "DISABLE_ROUTER_LOG", "log", "logger.router.MODE", "1.21")
|
||||
if val := sec.Key("ROUTER").String(); val != "" {
|
||||
sec.Key("logger.router.MODE").MustString(val)
|
||||
// Priority: `DISABLE_ROUTER_LOG` -> `LOGGER_ROUTER_MODE` -> `logger.router.MODE` -> `ROUTER`
|
||||
deprecatedSettingWarning(rootCfg, "log", "ROUTER", "log", "LOGGER_ROUTER_MODE")
|
||||
deprecatedSettingWarning(rootCfg, "log", "DISABLE_ROUTER_LOG", "log", "LOGGER_ROUTER_MODE")
|
||||
deprecatedSettingWarning(rootCfg, "log", "logger.router.MODE", "log", "LOGGER_ROUTER_MODE")
|
||||
hasNoValue = !sec.HasKey("LOGGER_ROUTER_MODE")
|
||||
if hasNoValue && sec.HasKey("logger.router.MODE") {
|
||||
sec.Key("LOGGER_ROUTER_MODE").SetValue(sec.Key("logger.router.MODE").String())
|
||||
hasNoValue = false
|
||||
}
|
||||
if !sec.HasKey("logger.router.MODE") {
|
||||
sec.Key("logger.router.MODE").MustString(",") // use default logger
|
||||
if val := sec.Key("ROUTER").String(); hasNoValue && val != "" {
|
||||
sec.Key("LOGGER_ROUTER_MODE").SetValue(val)
|
||||
hasNoValue = false
|
||||
}
|
||||
if sec.HasKey("DISABLE_ROUTER_LOG") && sec.Key("DISABLE_ROUTER_LOG").MustBool() {
|
||||
sec.Key("logger.router.MODE").SetValue("")
|
||||
sec.Key("LOGGER_ROUTER_MODE").SetValue("")
|
||||
hasNoValue = false
|
||||
}
|
||||
if hasNoValue {
|
||||
sec.Key("LOGGER_ROUTER_MODE").SetValue(",") // use default logger
|
||||
}
|
||||
|
||||
deprecatedSetting(rootCfg, "log", "XORM", "log", "logger.xorm.MODE", "1.21")
|
||||
deprecatedSetting(rootCfg, "log", "ENABLE_XORM_LOG", "log", "logger.xorm.MODE", "1.21")
|
||||
if val := sec.Key("XORM").String(); val != "" {
|
||||
sec.Key("logger.xorm.MODE").MustString(val)
|
||||
// Priority: `ENABLE_XORM_LOG` -> `LOGGER_XORM_MODE` -> `logger.xorm.MODE` -> `XORM`
|
||||
deprecatedSettingWarning(rootCfg, "log", "XORM", "log", "LOGGER_XORM_MODE")
|
||||
deprecatedSettingWarning(rootCfg, "log", "ENABLE_XORM_LOG", "log", "LOGGER_XORM_MODE")
|
||||
deprecatedSettingWarning(rootCfg, "log", "logger.xorm.MODE", "log", "LOGGER_XORM_MODE")
|
||||
hasNoValue = !sec.HasKey("LOGGER_XORM_MODE")
|
||||
if hasNoValue && sec.HasKey("logger.xorm.MODE") {
|
||||
sec.Key("LOGGER_XORM_MODE").SetValue(sec.Key("logger.xorm.MODE").String())
|
||||
hasNoValue = false
|
||||
}
|
||||
if !sec.HasKey("logger.xorm.MODE") {
|
||||
sec.Key("logger.xorm.MODE").MustString(",") // use default logger
|
||||
if val := sec.Key("XORM").String(); hasNoValue && val != "" {
|
||||
sec.Key("LOGGER_XORM_MODE").SetValue(val)
|
||||
hasNoValue = false
|
||||
}
|
||||
if sec.HasKey("ENABLE_XORM_LOG") && !sec.Key("ENABLE_XORM_LOG").MustBool() {
|
||||
sec.Key("logger.xorm.MODE").SetValue("")
|
||||
sec.Key("LOGGER_XORM_MODE").SetValue("")
|
||||
hasNoValue = false
|
||||
}
|
||||
if hasNoValue {
|
||||
sec.Key("LOGGER_XORM_MODE").SetValue(",") // use default logger
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -217,14 +249,14 @@ func initManagedLoggers(manager *log.LoggerManager, cfg ConfigProvider) {
|
|||
|
||||
func initLoggerByName(manager *log.LoggerManager, rootCfg ConfigProvider, loggerName string) {
|
||||
sec := rootCfg.Section("log")
|
||||
keyPrefix := "logger." + loggerName
|
||||
key := "LOGGER_" + strings.ToUpper(loggerName) + "_MODE"
|
||||
|
||||
disabled := sec.HasKey(keyPrefix+".MODE") && sec.Key(keyPrefix+".MODE").String() == ""
|
||||
disabled := sec.HasKey(key) && sec.Key(key).String() == ""
|
||||
if disabled {
|
||||
return
|
||||
}
|
||||
|
||||
modeVal := sec.Key(keyPrefix + ".MODE").String()
|
||||
modeVal := sec.Key(key).String()
|
||||
if modeVal == "," {
|
||||
modeVal = Log.Mode
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue