Nebo15 / logger_json

JSON logger formatter with support for Google Cloud, DataDog and other for Elixir.
https://nebo15.github.io/logger_json/
MIT License
237 stars 92 forks source link

Dialyzer warnings: Ecto.LogEntry and DatadogLogger pattern match #76

Closed woylie closed 3 years ago

woylie commented 3 years ago

I fixed some Dialyzer warnings in #75, but there are two left:

:0:unknown_type
Unknown type: Ecto.LogEntry.t/0.

Ecto.LogEntry has been removed in Ecto 3.2.0. If you want to keep this for backwards compatibility, we can tell Dialyzer to ignore this warning.

________________________________________________________________________________
lib/logger_json/formatters/datadog_logger.ex:43:pattern_match
The pattern can never match the type.

Pattern:
%{:reason => _reason}

Type:
nil | %Jason.Fragment{:encode => ({_, _} -> [any(), ...])}

I'm not using the datalog logger, but it looks like Jason.Helpers.json_map/1 (used in LoggerJSON.FormatterUtils.format_process_crash/1) returns a Jason.Fragment struct, on which you'd have to call the encode function in order to get the final map. The datadog logger matches on the encoded map though, and not on Jason.Fragment. So this looks like a bug to me.

AndrewDryga commented 3 years ago

Thank you @woylie, I fixed the bug you found via Dialyzer and removed Ecto.LogEntry struct name but kept the code for backward compatibility. ❤️