Replication can indeed improve performance, but it will lead to this instant.If a new hook is added, the hook may not be triggered

This commit is contained in:
liwei 2021-09-13 13:47:16 +08:00
parent 08bbc96fbf
commit 544f676a0d
1 changed files with 4 additions and 8 deletions

View File

@ -269,18 +269,14 @@ func (entry *Entry) getBufferPool() (pool BufferPool) {
}
func (entry *Entry) fireHooks() {
var tmpHooks LevelHooks
//Replication can indeed improve performance, but it will lead to this instant.
//If a new hook is added, the hook may not be triggered
entry.Logger.mu.Lock()
tmpHooks = make(LevelHooks, len(entry.Logger.Hooks))
for k, v := range entry.Logger.Hooks {
tmpHooks[k] = v
}
entry.Logger.mu.Unlock()
err := tmpHooks.Fire(entry.Level, entry)
err := entry.Logger.Hooks.Fire(entry.Level, entry)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to fire hook: %v\n", err)
}
entry.Logger.mu.Unlock()
}
func (entry *Entry) write() {