Nebo15 / logger_json

JSON logger formatter with support for Google Cloud, DataDog and other for Elixir.

Home Page:https://nebo15.github.io/logger_json/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dialyzer warnings: Ecto.LogEntry and DatadogLogger pattern match

woylie opened this issue · comments

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.

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