Skip to content

Commit

Permalink
Try grabbing metadata before slicing and logging separately.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivor committed Sep 28, 2024
1 parent 6fbdeff commit ad09614
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/tesla/middleware/meta_logger.ex
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,14 @@ if Code.ensure_loaded?(Tesla) do
end

defp log(message, level, options) when is_binary(message) do
# Grabbing metadata here incase the caller process dies
metadata = MetaLogger.metadata()
max_entry_length = Keyword.get(options, :max_entry_length)

message
|> Slicer.slice(max_entry_length)
|> Enum.map(&prepend_tag(&1, options))
|> Enum.each(&MetaLogger.log(level, &1))
|> Enum.each(&MetaLogger.log(level, &1, metadata))
end

defp log(message, level, options), do: log(inspect(message), level, options)
Expand Down

0 comments on commit ad09614

Please sign in to comment.