diff options
author | Patrick Steinhardt <ps@pks.im> | 2023-08-18 10:01:01 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2023-08-18 11:21:25 +0300 |
commit | 7d71af0efe6e8e4b3c7a03bb63adfd011140887d (patch) | |
tree | fe7a9d57706feced97d3fc12474b3b4472e68ede /internal/testhelper | |
parent | 1f485017eea02f476650211525f54d406b279775 (diff) |
log: Return errors when logger configuration fails
When configuration of the logger fails then we print a log message via
the logrus package. This has the problem that this logger is not yet
properly configured and thus may or may not be the correct thing to do.
Refactor the code to instead return an error when configuration of the
logger fails. This lets callers handle the error appropriately by
themselves.
Diffstat (limited to 'internal/testhelper')
-rw-r--r-- | internal/testhelper/configure.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/internal/testhelper/configure.go b/internal/testhelper/configure.go index 399e20bfc..537485239 100644 --- a/internal/testhelper/configure.go +++ b/internal/testhelper/configure.go @@ -81,7 +81,10 @@ func Run(m *testing.M, opts ...RunOption) { // configure sets up the global test configuration. On failure, // terminates the program. func configure() (_ func(), returnedErr error) { - logger := log.Configure(os.Stdout, "json", "panic") + logger, err := log.Configure(os.Stdout, "json", "panic") + if err != nil { + return nil, fmt.Errorf("configuring logger failed: %w", err) + } for key, value := range map[string]string{ // We inject the following two variables, which instruct Git to search its |