Closed lwydyby closed 3 years ago
This issue is stale because it has been open for 30 days with no activity.
I've seen your PR, you should always use ReplaceHooks
to remove a specific hook instead of modifying the Hooks
directly.
// ReplaceHooks replaces the logger hooks and returns the old ones
func (logger *Logger) ReplaceHooks(hooks LevelHooks) LevelHooks {
logger.mu.Lock()
oldHooks := logger.Hooks
logger.Hooks = hooks
logger.mu.Unlock()
return oldHooks
}
type LevelHooks map[Level][]Hook
I have used ReplaceHooks
,But this method cannot replace a specific hook. I can only traverse to remove the previously registered hook separately, and then call ReplaceHooks
,If the lock is not provided, is there any other way to get LevelHooks
you mean is to pass an empty map first, get the old map, then traverse the old map, and then replace the map after the modification is completed ? But this will cause the log to not trigger the correct hook for a period of time
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.
gist: https://gist.github.com/lwydyby/58700d6ea1082d25ecc46049633243c7 error log: