From 71149e36fae163523d81f0cf23da3a64129e0f33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorben=20G=C3=BCnther?= Date: Sun, 20 Oct 2024 14:32:56 +0200 Subject: [PATCH 1/3] Add configurable logging level for jobs This changes the default for JobLoggerLevel from "trace" to "info". Closes #298 --- internal/app/run/runner.go | 9 +++++++++ internal/pkg/config/config.example.yaml | 2 ++ internal/pkg/config/config.go | 6 +++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/internal/app/run/runner.go b/internal/app/run/runner.go index e8654b6..e774786 100644 --- a/internal/app/run/runner.go +++ b/internal/app/run/runner.go @@ -232,6 +232,15 @@ func (r *Runner) run(ctx context.Context, task *runnerv1.Task, reporter *report. Inputs: inputs, } + if r.cfg.Log.JobLevel != "" { + level, err := log.ParseLevel(r.cfg.Log.JobLevel) + if err != nil { + return err + } + + runnerConfig.JobLoggerLevel = &level + } + rr, err := runner.New(runnerConfig) if err != nil { return err diff --git a/internal/pkg/config/config.example.yaml b/internal/pkg/config/config.example.yaml index 88bc2c6..20218ae 100644 --- a/internal/pkg/config/config.example.yaml +++ b/internal/pkg/config/config.example.yaml @@ -6,6 +6,8 @@ log: # The level of logging, can be trace, debug, info, warn, error, fatal level: info + # The level of logging for jobs, can be trace, debug, info, earn, error, fatal + job_level: info runner: # Where to store the registration result. diff --git a/internal/pkg/config/config.go b/internal/pkg/config/config.go index a1536b3..5ab177d 100644 --- a/internal/pkg/config/config.go +++ b/internal/pkg/config/config.go @@ -16,7 +16,8 @@ import ( // Log represents the configuration for logging. type Log struct { - Level string `yaml:"level"` // Level indicates the logging level. + Level string `yaml:"level"` // Level indicates the logging level. + JobLevel string `yaml:"job_level"` // JobLevel indicates the job logging level. } // Runner represents the configuration for the runner. @@ -113,6 +114,9 @@ func LoadDefault(file string) (*Config, error) { if cfg.Log.Level == "" { cfg.Log.Level = "info" } + if cfg.Log.JobLevel == "" { + cfg.Log.JobLevel = "info" + } if cfg.Runner.File == "" { cfg.Runner.File = ".runner" } From 846ff2a616634540c641729182429c93dd6b726e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorben=20G=C3=BCnther?= Date: Wed, 30 Oct 2024 22:11:19 +0100 Subject: [PATCH 2/3] Add simple test --- internal/pkg/config/config_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/pkg/config/config_test.go b/internal/pkg/config/config_test.go index d2ddf2f..af3ebf7 100644 --- a/internal/pkg/config/config_test.go +++ b/internal/pkg/config/config_test.go @@ -35,3 +35,10 @@ func TestConfigTune(t *testing.T) { assert.EqualValues(t, 2*time.Second, c.Runner.FetchInterval) }) } + +func TestDefaultSettings(t *testing.T) { + config, err := LoadDefault("") + assert.NoError(t, err) + + assert.EqualValues(t, config.Log.JobLevel, "info") +} From 8b2242d893d405f87a5402bc595d69f45ec1680f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorben=20G=C3=BCnther?= Date: Sat, 2 Nov 2024 20:32:13 +0100 Subject: [PATCH 3/3] Update release notes. --- RELEASE-NOTES.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 55a49f0..f899d14 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -1,5 +1,9 @@ # Release Notes +## 4.1.0 + +* [Add job_level logging option to config](https://code.forgejo.org/forgejo/runner/pulls/299) to make the logging level of jobs configurable. Change default from "trace" to "info". + ## 4.0.1 * Do not panic when [the number of arguments of a function evaluated in an expression is incorect](https://code.forgejo.org/forgejo/act/pulls/59/files).