Skip to content

Commit

Permalink
Fix Plugin.SetOutputTarget fallback behavior
Browse files Browse the repository at this point in the history
Correctly fallback to default output target when an invalid
output target is provided.

refs GH-267
  • Loading branch information
atc0005 committed Oct 17, 2024
1 parent 8d803d5 commit df5e49a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion nagios.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,11 +467,14 @@ func (p *Plugin) AddUniqueError(errs ...error) {
}

// SetOutputTarget assigns a target for Nagios plugin output. By default
// output is emitted to os.Stdout.
// output is emitted to os.Stdout. If given an invalid output target the
// default output target will be used instead.
func (p *Plugin) SetOutputTarget(w io.Writer) {
// Guard against potential nil argument.
if w == nil {
p.outputSink = os.Stdout

return
}

p.outputSink = w
Expand Down

0 comments on commit df5e49a

Please sign in to comment.