Skip to content

Commit

Permalink
Make pretty JSON formatting optional in basic formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
hkrutzer committed Apr 25, 2024
1 parent 29bc599 commit 24cc0df
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/logger_json/formatters/basic.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ defmodule LoggerJSON.Formatters.Basic do

@spec format(any(), any()) :: none()
def format(%{level: level, meta: meta, msg: msg}, opts) do
pretty_json = Keyword.get(opts, :pretty_json, true)
metadata_keys_or_selector = Keyword.get(opts, :metadata, [])
metadata_selector = update_metadata_selector(metadata_keys_or_selector, @processed_metadata_keys)

Expand All @@ -44,7 +45,7 @@ defmodule LoggerJSON.Formatters.Basic do
|> maybe_put(:request, format_http_request(meta))
|> maybe_put(:span, format_span(meta))
|> maybe_put(:trace, format_trace(meta))
|> Jason.encode_to_iodata!(pretty: true)
|> Jason.encode_to_iodata!(pretty: pretty_json)

[line, "\n"]
end
Expand Down

0 comments on commit 24cc0df

Please sign in to comment.