diff options
author | 2024-04-04 17:42:42 +0200 | |
---|---|---|
committer | 2024-04-04 16:42:42 +0100 | |
commit | 236604bd6beb50d84ac1df193a3dbe5b482948d9 (patch) | |
tree | a8f7bd1963b4c8898d055089eacde5d6eebdfd51 /testrig/config.go | |
parent | [bugfix] Sort follows chronologically (#2801) (diff) | |
download | gotosocial-236604bd6beb50d84ac1df193a3dbe5b482948d9.tar.xz |
[chore] Log less output on failed test (#2804)
* [chore] Log less output on failed test
This changes the testrig log level to be error by default instead of
info. This makes test failures a lot easier to read, as we don't have
the parade of info logs for each failure to scroll through.
It speeds up the test suite by a couple of seconds since we need
to buffer and flush a lot less messages. On a clean run, so no test
failures, it's about a 3s difference on my machine. Depending on the
amount of test failures, total time saved can vary.
This also introduces a GTS_TESTRIG_LOG_LEVEL environment variable that
we explicitly check for, making it easy to override the log level should
we have a need for it. This would be primarily for running locally, and
not so much as part of go test.
Lastly, it updates the syslog tests to use log.Error because if the log
level is set to error but we call log.Info no message is emitted and we
hang indefinitely on the channel read.
* [chore] Rename the testrig log level env var
Diffstat (limited to 'testrig/config.go')
-rw-r--r-- | testrig/config.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/testrig/config.go b/testrig/config.go index c3a62aed4..d33c4ac8c 100644 --- a/testrig/config.go +++ b/testrig/config.go @@ -18,6 +18,7 @@ package testrig import ( + "os" "time" "codeberg.org/gruf/go-bytesize" @@ -33,8 +34,16 @@ func InitTestConfig() { }) } +func logLevel() string { + level := "error" + if lv := os.Getenv("GTS_LOG_LEVEL"); lv != "" { + level = lv + } + return level +} + var testDefaults = config.Configuration{ - LogLevel: "info", + LogLevel: logLevel(), LogTimestampFormat: "02/01/2006 15:04:05.000", LogDbQueries: true, ApplicationName: "gotosocial", |