Skip to content

Commit 8c94d5e

Browse files
committed
Add logging levels to custom plugin logs.
1 parent 7fa3454 commit 8c94d5e

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

pkg/custompluginmonitor/custom_plugin_monitor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ func (c *customPluginMonitor) generateStatus(result cpmtypes.Result) *types.Stat
271271
}
272272
// Log only if condition has changed
273273
if len(activeProblemEvents) != 0 || len(inactiveProblemEvents) != 0 {
274-
glog.Infof("New status generated: %+v", status)
274+
glog.V(0).Infof("New status generated: %+v", status)
275275
}
276276
return status
277277
}

pkg/custompluginmonitor/plugin/plugin.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ func (p *Plugin) runRules() {
115115

116116
// Let the result be logged at a higher verbosity level. If there is a change in status it is logged later.
117117
glog.V(3).Infof("Add check result %+v for rule %+v", result, rule)
118-
glog.Infof("Ran rule %+v", rule)
119118
}(rule)
120119
}
121120

@@ -219,12 +218,13 @@ func (p *Plugin) run(rule cpmtypes.CustomRule) (exitStatus cpmtypes.Status, outp
219218
exitCode := cmd.ProcessState.Sys().(syscall.WaitStatus).ExitStatus()
220219
switch exitCode {
221220
case 0:
221+
logPluginStderr(rule, string(stderr), 3)
222222
return cpmtypes.OK, output
223223
case 1:
224-
logPluginStderr(rule.Path, string(stderr))
224+
logPluginStderr(rule, string(stderr), 0)
225225
return cpmtypes.NonOK, output
226226
default:
227-
logPluginStderr(rule.Path, string(stderr))
227+
logPluginStderr(rule, string(stderr), 0)
228228
return cpmtypes.Unknown, output
229229
}
230230
}
@@ -234,9 +234,9 @@ func (p *Plugin) Stop() {
234234
glog.Info("Stop plugin execution")
235235
}
236236

237-
func logPluginStderr(path, logs string) {
237+
func logPluginStderr(rule cpmtypes.CustomRule, logs string, logLevel glog.Level) {
238238
if len(logs) != 0 {
239-
glog.Infof("Start logs from plugin %q \n %s", path, string(logs))
240-
glog.Infof("End logs from plugin %q", path)
239+
glog.V(logLevel).Infof("Start logs from plugin %+v \n %s", rule, logs)
240+
glog.V(logLevel).Infof("End logs from plugin %+v", rule)
241241
}
242242
}

0 commit comments

Comments
 (0)