overriding Logger to prepend __MODULE__ in output

Viewed 80

is it possible in Elixir to override the Logger functions to always prepend the module where it is being called? "[#{__MODULE__}] "

like

Logger.debug("Fetching Exchange Information and Trading Rules...")

becomes in log:

[debug] [Elixir.Binance.Futures.Rest.Client] Requesting Exchange Information and Trading Rules...

1 Answers

The requested functionality is already there. Just configure Logger to output the respective metadata (:mfa) as described in the documentation.

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