Skip to content

Commit

Permalink
Better naming for redactor/encoder module
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewDryga committed May 14, 2024
1 parent 44e76af commit 81b3f0a
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule LoggerJSON.Formatter.Encoder do
defmodule LoggerJSON.Formatter.RedactorEncoder do
@doc """
Takes a term and makes sure that it can be encoded by Jason.encode!/1 without errors
and without leaking sensitive information.
Expand All @@ -18,6 +18,7 @@ defmodule LoggerJSON.Formatter.Encoder do
`keyword()` | converted to map | values are redacted
`%Jason.Fragment{}` | unchanged | unchanged
everything else | using `inspect/2` | unchanged
"""

@type redactor :: {redactor :: module(), redactor_opts :: term()}
Expand Down
2 changes: 1 addition & 1 deletion lib/logger_json/formatters/basic.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ defmodule LoggerJSON.Formatters.Basic do
}
"""
import Jason.Helpers, only: [json_map: 1]
import LoggerJSON.Formatter.{MapBuilder, DateTime, Message, Metadata, Plug, Encoder}
import LoggerJSON.Formatter.{MapBuilder, DateTime, Message, Metadata, Plug, RedactorEncoder}

@behaviour LoggerJSON.Formatter

Expand Down
2 changes: 1 addition & 1 deletion lib/logger_json/formatters/datadog.ex
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ defmodule LoggerJSON.Formatters.Datadog do
}
"""
import Jason.Helpers, only: [json_map: 1]
import LoggerJSON.Formatter.{MapBuilder, DateTime, Message, Metadata, Code, Plug, Encoder}
import LoggerJSON.Formatter.{MapBuilder, DateTime, Message, Metadata, Code, Plug, RedactorEncoder}

@behaviour LoggerJSON.Formatter

Expand Down
2 changes: 1 addition & 1 deletion lib/logger_json/formatters/google_cloud.ex
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ defmodule LoggerJSON.Formatters.GoogleCloud do
}
"""
import Jason.Helpers, only: [json_map: 1]
import LoggerJSON.Formatter.{MapBuilder, DateTime, Message, Metadata, Code, Plug, Encoder}
import LoggerJSON.Formatter.{MapBuilder, DateTime, Message, Metadata, Code, Plug, RedactorEncoder}

@behaviour LoggerJSON.Formatter

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule LoggerJSON.Formatter.EncoderTest do
defmodule LoggerJSON.Formatter.RedactorEncoderTest do
use LoggerJSON.Case, async: true
use ExUnitProperties
import LoggerJSON.Formatter.Encoder
import LoggerJSON.Formatter.RedactorEncoder

defmodule IDStruct, do: defstruct(id: nil)

Expand Down Expand Up @@ -79,7 +79,7 @@ defmodule LoggerJSON.Formatter.EncoderTest do
end

test "inspects functions" do
assert encode(&encode/2, []) == "&LoggerJSON.Formatter.Encoder.encode/2"
assert encode(&encode/2, []) == "&LoggerJSON.Formatter.RedactorEncoder.encode/2"
end

test "inspects pids" do
Expand Down

0 comments on commit 81b3f0a

Please sign in to comment.