Skip to content

Commit

Permalink
Small tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivor committed Oct 7, 2024
1 parent 1cbee1a commit 5b2dc0a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions lib/meta_logger/slicer.ex
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
defmodule MetaLogger.Slicer do
@moduledoc """
Responsible for slicing log entries according to the given max length option.
A bebaviour for slicing long entries into a list of entries shorter than a passed `max_entry_length` value.
"""

@typedoc "Max length in bytes or `:infinity` if the entry should not be sliced."
@type max_entry_length :: non_neg_integer() | :infinity
@callback slice(String.t(), max_entry_length()) :: [String.t()]

defmodule Default do
defmodule DefaultImpl do
@moduledoc """
Responsible for slicing log entries according to the given max length option.
"""

@behaviour MetaLogger.Slicer
@doc """
Returns sliced log entries according to the given max entry length.
Expand Down
2 changes: 1 addition & 1 deletion lib/tesla/middleware/meta_logger.ex
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ if Code.ensure_loaded?(Tesla) do
|> maybe_put_default_value(:log_level, :info)
|> maybe_put_default_value(:log_tag, __MODULE__)
|> maybe_put_default_value(:max_entry_length, :infinity)
|> maybe_put_default_value(:slicer, MetaLogger.Slicer.Default)
|> maybe_put_default_value(:slicer, MetaLogger.Slicer.DefaultImpl)
end

@spec maybe_put_default_values(Env.opts(), [atom()], any()) :: Env.opts()
Expand Down
2 changes: 1 addition & 1 deletion test/tesla/middleware/meta_logger_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ defmodule Tesla.Middleware.MetaLoggerTest do
@behaviour MetaLogger.Slicer

@impl MetaLogger.Slicer
def slice(entry, _max_entry_length) do
def slice(_entry, _max_entry_length) do
["slice1", "slice2"]
end
end
Expand Down

0 comments on commit 5b2dc0a

Please sign in to comment.