View Source Credo.Check.Warning.MissedMetadataKeyInLoggerConfig (Credo v1.7.0)

This check has a base priority of high and works with any version of Elixir.

explanation

Explanation

Ensures custom metadata keys are included in logger config

Note that all metadata is optional and may not always be available.

For example, you might wish to include a custom :error_code metadata in your logs:

Logger.error("We have a problem", [error_code: :pc_load_letter])

In your app's logger configuration, you would need to include the :error_code key:

config :logger, :console,
  format: "[$level] $message $metadata\n",
  metadata: [:error_code, :file]

That way your logs might then receive lines like this:

[error] We have a problem error_code=pc_load_letter file=lib/app.ex

check-specific-parameters

Check-Specific Parameters

Use the following parameters to configure this check:

ignore_logger_functions

:ignore_logger_functions

Do not raise an issue for these Logger functions.

This parameter defaults to nil.

metadata_keys

:metadata_keys

Do not raise an issue for these Logger metadata keys.

By default, we assume the metadata keys listed under your console backend.

This parameter defaults to [].

general-parameters

General Parameters

Like with all checks, general params can be applied.

Parameters can be configured via the .credo.exs config file.