Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check if Decimal is loaded in encoder #135

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/logger_json/formatter/redactor_encoder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ defmodule LoggerJSON.Formatter.RedactorEncoder do
def encode(%DateTime{} = datetime, _redactors), do: datetime
def encode(%Date{} = date, _redactors), do: date
def encode(%Time{} = time, _redactors), do: time
def encode(%Decimal{} = decimal, _redactors), do: decimal

if Code.ensure_loaded?(Decimal) do
def encode(%Decimal{} = decimal, _redactors), do: decimal
end

def encode(%_struct{} = struct, redactors) do
struct
Expand Down
1 change: 1 addition & 0 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ defmodule LoggerJSON.Mixfile do
[
{:jason, "~> 1.4"},
{:plug, "~> 1.15", optional: true},
{:decimal, ">= 0.0.0", optional: true},
{:ecto, "~> 3.11", optional: true},
{:telemetry, "~> 1.0", optional: true},
{:stream_data, "~> 1.0", only: [:dev, :test]},
Expand Down
Loading