View Source CozyLogger.JSON (cozy_logger v1.0.0)

Formatting log messages as JSON.

usage

Usage

Elixir v1.15 or later:

# customize format message with this formatter.
config :logger, :default_formatter,
  format: {CozyLogger.JSON, :format},
  truncate: :infinity,
  utc_log: true,
  metadata: :all,
  colors: [enabled: false]

Prior to Elixir v1.15:

# use Elixir built-in console backend, and configure other necessary options
config :logger,
  backends: [:console],
  truncate: :infinity,
  utc_log: true

# customize format message with this formatter.
config :logger, :console,
  format: {CozyLogger.JSON, :format},
  metadata: :all,
  colors: [enabled: false]

Link to this section Summary

Link to this section Types

@type date() :: {1970..10000, 1..12, 1..31}
@type date_time_ms() :: {date(), time_ms()}
@type time_ms() :: {0..23, 0..59, 0..59, 0..999}

Link to this section Functions

Link to this function

format(level, message, timestamp, metadata)

View Source
@spec format(atom(), term(), date_time_ms(), keyword()) :: IO.chardata()