-
Notifications
You must be signed in to change notification settings - Fork 418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MissedMetadataKeyInLoggerConfig shouldn't warn if you don't use the console logger backend #1027
Comments
I can submit a patch to change the behavior if this seems appropriate. |
Understood. The only thing that is important is that we can not compile or execute code from the analyzed project in Credo, because it is a static analysis tool that "just looks at the code". We might already have violated that rule with the check's current implementation, which does not work for situations where Maybe we should just provide an example to configure the check (as proposed by @milmazz at the start of his original PR): # uncomment an modify this to your needs:
{Credo.Check.Warning.IgnoredLoggerMetadata, [metadata_keys: "config/prod.exs" |> Config.Reader.read!() |> get_in([:logger, :console, :metadata])]}, we can do this because WDYT? |
I upgraded to 1.7 today and I ended up just disabling this check. |
That would be a good improvement. In the check's explanation? I had to configure the check in my project to make it work too, for the same reason as is the topic of this issue 🙂 In case anyone is reading this thread half-asleep, rrrene's example needs to be modified to work: {Credo.Check.Warning.IgnoredLoggerMetadata, [metadata_keys: "config/prod.exs" |> Config.Reader.read!() |> get_in([:logger, :console, :metadata])]}, First, the check's module name is different. Second, if you hit this problem because you don't have the console backend in production, you need to pass the name of your actual logger backend. In my case it's {Credo.Check.Warning.MissedMetadataKeyInLoggerConfig,
[
metadata_keys:
"config/prod.exs" |> Config.Reader.read!() |> get_in([:logger, :file_log, :metadata])
]} |
This is part of |
This is part of Credo |
Precheck
Environment
mix credo -v
): 1.7.0-rc.1elixir -v
):What were you trying to do?
I was going to test out the RC release, and noticed we get a lot of warning for the new check
MissedMetadataKeyInLoggerConfig
.We do not use the
:console
logger backend in production, so these are false positives.Expected outcome
Should only warn if the
:console
backend is configured for that env.Actual outcome
False positives.
cc @milmazz as the author of this new check in #952
The text was updated successfully, but these errors were encountered: