error in one Hook.Fire() prevents subsequent hooks from firing
Author: tochiaiCreated Aug 31, 2016Updated Mar 9, 2026
Labelsenhancementstale
The loop in LevelHooks.Fire() is interrupted when there is an error, which is undesirable in our use case. This is different behavior from the doc comment:
// Fire all the hooks for the passed level.
Our workaround is to LevelHooks.Add() the hooks in order of increasing likelihood of an error so that the loop will not terminate prematurely.
We think it is preferable to allow all of the hooks in LevelHooks to attempt to fire. This can be accomplished by using go-multierror to capture errors as they arise, and then return the collective error after the loop has fired all the hooks for a log level. I'm happy to submit a PR if this seems like a desirable change.
Thanks!
Source: sirupsen/logrus