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:
Michael Kriese 2025-08-01 10:55:05 +02:00 committed by Michael Kriese
commit f185a4ce67
7 changed files with 100 additions and 36 deletions

View file

@ -251,8 +251,8 @@ ENABLE_ACCESS_LOG = false
func TestLogConfigNewConfig(t *testing.T) {
manager, managerClose := initLoggersByConfig(t, `
[log]
logger.access.MODE = console
logger.xorm.MODE = console, console-1
LOGGER_ACCESS_MODE = console
LOGGER_XORM_MODE = console, console-1
[log.console]
LEVEL = warn
@ -421,7 +421,7 @@ func TestLegacyLoggerMigrations(t *testing.T) {
}
t.Run("default", func(t *testing.T) {
runCases(t, "logger.default.MODE", Cases{
runCases(t, "LOGGER_DEFAULT_MODE", Cases{
{
"uses default value for default logger",
"",
@ -438,7 +438,7 @@ logger.default.MODE = file
})
t.Run("access", func(t *testing.T) {
runCases(t, "logger.access.MODE", Cases{
runCases(t, "LOGGER_ACCESS_MODE", Cases{
{
"uses default value for access logger",
"",
@ -475,6 +475,14 @@ logger.access.MODE = console
`,
"console",
},
{
"LOGGER_ACCESS_MODE has precedence over logger.access.MODE for access logger",
`[log]
LOGGER_ACCESS_MODE = file
logger.access.MODE = console
`,
"file",
},
{
"ENABLE_ACCESS_LOG doesn't enable access logger",
`[log]
@ -486,7 +494,7 @@ ENABLE_ACCESS_LOG = true
})
t.Run("router", func(t *testing.T) {
runCases(t, "logger.router.MODE", Cases{
runCases(t, "LOGGER_ROUTER_MODE", Cases{
{
"uses default value for router logger",
"",
@ -523,11 +531,19 @@ logger.router.MODE = console
`,
"console",
},
{
"LOGGER_ROUTER_MODE has precedence over logger.router.MODE for router logger",
`[log]
LOGGER_ROUTER_MODE = file
logger.router.MODE = console
`,
"file",
},
})
})
t.Run("xorm", func(t *testing.T) {
runCases(t, "logger.xorm.MODE", Cases{
runCases(t, "LOGGER_XORM_MODE", Cases{
{
"uses default value for xorm logger",
"",
@ -564,6 +580,14 @@ logger.xorm.MODE = console
`,
"console",
},
{
"LOGGER_XORM_MODE has precedence over logger.xorm.MODE for xorm logger",
`[log]
LOGGER_XORM_MODE = file
logger.xorm.MODE = console
`,
"file",
},
})
})
}