| 1 | package logrusscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/ |
| 2 | |
| 3 | // A hook to be fired when logging on the logging levels returned from |
| 4 | // `Levels()` on your implementation of the interface. Note that this is not |
| 5 | // fired in a goroutine or a channel with workers, you should handle such |
| 6 | // functionality yourself if your call is non-blocking and you don't wish for |
| 7 | // the logging calls for levels returned from `Levels()` to block. |
| 8 | type Hookscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Hook# interface { |
| 9 | Levelsscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Hook#Levels.() []Levelscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Level# |
| 10 | Firescip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Hook#Fire.(*Entryscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#) error |
| 11 | } |
| 12 | |
| 13 | // Internal type for storing the hooks on a logger instance. |
| 14 | type LevelHooksscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/LevelHooks# map[Levelscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Level#][]Hookscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Hook# |
| 15 | |
| 16 | // Add a hook to an instance of logger. This is called with |
| 17 | // `log.Hooks.Add(new(MyHook))` where `MyHook` implements the `Hook` interface. |
| 18 | func (hooks LevelHooksscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/LevelHooks#) Addscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/LevelHooks#Add().(hook Hookscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Hook#) { |
| 19 | for _, level := range hook.Levelsscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Hook#Levels.() { |
| 20 | hooks[level] = append(hooks[level], hook) |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | // Fire all the hooks for the passed level. Used by `entry.log` to fire |
| 25 | // appropriate hooks for a log entry. |
| 26 | func (hooks LevelHooksscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/LevelHooks#) Firescip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/LevelHooks#Fire().(level Levelscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Level#, entry *Entryscip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Entry#) error { |
| 27 | for _, hook := range hooks[level] { |
| 28 | if err := hook.Firescip-go gomod github.com/sirupsen/logrus . `github.com/sirupsen/logrus`/Hook#Fire.(entry); err != nil { |
| 29 | return err |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | return nil |
| 34 | } |