mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-10-31 22:40:01 +00:00
[chore] Update setting testrig loglevel (#2870)
cmp.Or was introduced in Go 1.22 and picks the first value that's not the zero value for the type. For a string, the zero value is the empty string, which is what os.Getenv will return if the environment variable is not set. That then results in "error" being returned instead. This allows loading an environment variable with a default without having to do the check and write out the conditional.
This commit is contained in:
parent
fd8a724e77
commit
6c9bc26a6d
1 changed files with 2 additions and 9 deletions
|
@ -18,6 +18,7 @@
|
||||||
package testrig
|
package testrig
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"cmp"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -34,16 +35,8 @@ func InitTestConfig() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func logLevel() string {
|
|
||||||
level := "error"
|
|
||||||
if lv := os.Getenv("GTS_LOG_LEVEL"); lv != "" {
|
|
||||||
level = lv
|
|
||||||
}
|
|
||||||
return level
|
|
||||||
}
|
|
||||||
|
|
||||||
var testDefaults = config.Configuration{
|
var testDefaults = config.Configuration{
|
||||||
LogLevel: logLevel(),
|
LogLevel: cmp.Or(os.Getenv("GTS_LOG_LEVEL"), "error"),
|
||||||
LogTimestampFormat: "02/01/2006 15:04:05.000",
|
LogTimestampFormat: "02/01/2006 15:04:05.000",
|
||||||
LogDbQueries: true,
|
LogDbQueries: true,
|
||||||
ApplicationName: "gotosocial",
|
ApplicationName: "gotosocial",
|
||||||
|
|
Loading…
Reference in a new issue