rs / zerolog

Zero Allocation JSON Logger
MIT License
10.39k stars 566 forks source link

Retrieve logger fields from Zerolog event #587

Open jackhua222 opened 1 year ago

jackhua222 commented 1 year ago

I'm planning to use a hook to send logs to elsewhere on top of the logger. I know that the hook interface is like this:

type Hook interface {
    // Run runs the hook with the event.
    Run(e *Event, level Level, message string)
}

I'm interested to retrieve all the fields I've added to the logger context before sending the logs to elsewhere. I couldn't find anything obvious, is there a way to do this?

doctaweeks commented 1 year ago

493 might help