-
-
Save tj/0499e83305f99ca24d34 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Package multi implements a handler which invokes a number of handlers. | |
package multi | |
import ( | |
"github.com/apex/log" | |
) | |
// Handler implementation. | |
type Handler struct { | |
Handlers []log.Handler | |
} | |
// New handler. | |
func New(h ...log.Handler) *Handler { | |
return &Handler{ | |
Handlers: h, | |
} | |
} | |
// HandleLog implements log.Handler. | |
func (h *Handler) HandleLog(e *log.Entry) error { | |
for _, handler := range h.Handlers { | |
if err := handler.HandleLog(e); err != nil { | |
return err | |
} | |
} | |
return nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment