Add configurable logging level for jobs
This changes the default for JobLoggerLevel from "trace" to "info". Closes #298
This commit is contained in:
parent
907588cef5
commit
71149e36fa
3 changed files with 16 additions and 1 deletions
|
@ -232,6 +232,15 @@ func (r *Runner) run(ctx context.Context, task *runnerv1.Task, reporter *report.
|
||||||
Inputs: inputs,
|
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)
|
rr, err := runner.New(runnerConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
log:
|
log:
|
||||||
# The level of logging, can be trace, debug, info, warn, error, fatal
|
# The level of logging, can be trace, debug, info, warn, error, fatal
|
||||||
level: info
|
level: info
|
||||||
|
# The level of logging for jobs, can be trace, debug, info, earn, error, fatal
|
||||||
|
job_level: info
|
||||||
|
|
||||||
runner:
|
runner:
|
||||||
# Where to store the registration result.
|
# Where to store the registration result.
|
||||||
|
|
|
@ -17,6 +17,7 @@ import (
|
||||||
// Log represents the configuration for logging.
|
// Log represents the configuration for logging.
|
||||||
type Log struct {
|
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.
|
// Runner represents the configuration for the runner.
|
||||||
|
@ -113,6 +114,9 @@ func LoadDefault(file string) (*Config, error) {
|
||||||
if cfg.Log.Level == "" {
|
if cfg.Log.Level == "" {
|
||||||
cfg.Log.Level = "info"
|
cfg.Log.Level = "info"
|
||||||
}
|
}
|
||||||
|
if cfg.Log.JobLevel == "" {
|
||||||
|
cfg.Log.JobLevel = "info"
|
||||||
|
}
|
||||||
if cfg.Runner.File == "" {
|
if cfg.Runner.File == "" {
|
||||||
cfg.Runner.File = ".runner"
|
cfg.Runner.File = ".runner"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue