SaltDns.LogFormatter (Salt v1.0.0)

Log formatter for Erlang's :logger that scrubs secrets, in two modes:

  • :text - 2026-11-10T12:00:00.000000Z info [request_id] message
  • :json - one JSON object per line: time, level, message, request_id and a few metadata fields, for log collectors.

Whatever the mode, secrets never reach the output: API tokens (salt_<id>_<secret> keep their id and lose the secret), bearer credentials, and the exact values of the configured secrets (vault keys, secret_key_base, the OIDC client secret). This is a second line of defence; the code is also written not to log secrets in the first place (see test/salt_dns/log_redaction_test.exs).

Enabled in production by config/runtime.exs:

config :logger, :default_handler,
  formatter: {SaltDns.LogFormatter, %{mode: :json}}

(SALT_DNS_LOG_FORMAT=json).

Summary

Functions

:logger formatter callback.

Removes secrets from text.

Functions

format(map, config)

@spec format(:logger.log_event(), map()) :: iodata()

:logger formatter callback.

scrub(text)

@spec scrub(String.t()) :: String.t()

Removes secrets from text.