timber-elixir
timber-elixir copied to clipboard
Adds `to_event` support for arbitrary structs
Adds the ability to send structs as events in log metadata:
Logger.info("Something happened", event: %AnEvent{with_data: true})
Right now, doing this raises an exception and the log message is dropped:
(FunctionClauseError) no function clause matching in Timber.Eventable.Any.to_event/1
Use case
I'm using struct events in my project to represent something happening in the app and its associated data. In the event handler for those events, I'm adding the event itself as context to all logging. It doesn't work though, because Timber can't convert it.
This PR uses the struct name as the context namespace for its logged contents.
Pull Request Test Coverage Report for Build 915
- 3 of 3 (100.0%) changed or added relevant lines in 1 file are covered.
- No unchanged relevant lines lost coverage.
- Overall coverage increased (+0.4%) to 42.373%
| Totals | |
|---|---|
| Change from base Build 885: | 0.4% |
| Covered Lines: | 200 |
| Relevant Lines: | 472 |