handler.go 379 B

12345678910111213141516171819202122232425
  1. package log
  2. import "github.com/pkg/errors"
  3. type Handler interface {
  4. Log(level, msg string)
  5. Close() error
  6. }
  7. type Handlers []Handler
  8. func (hs Handlers) Log(level, msg string) {
  9. for _, h := range hs {
  10. h.Log(level, msg)
  11. }
  12. }
  13. func (hs Handlers) Close() (err error) {
  14. for _, h := range hs {
  15. if err = h.Close(); err != nil {
  16. err = errors.WithStack(err)
  17. }
  18. }
  19. return
  20. }