Skip to content

Commit

Permalink
Add tests for microsecond and newline
Browse files Browse the repository at this point in the history
  • Loading branch information
reachfh committed Apr 7, 2024
1 parent c2871b1 commit b8621a2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions mix_tests/test/logger_formatter_json_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ defmodule LoggerFormatterJsonTest do
expected = ~s({"msg":"hello world","level":"info"}\n)
assert expected == to_string(:logger_formatter_json.format(%{level: :info, msg: {'hello ~s', ['world']}, meta: %{}}, %{}))
end

test "String with microsecond" do
expected = ~s({"msg":"408\\u00B5s","level":"info"}\n)
assert expected == to_string(:logger_formatter_json.format(%{level: :info, msg: {:string, "408µs"}, meta: %{}}, %{}))
end

test "String with new line after microsecond" do
expected = ~s({"msg":"408\\u00B5s\\n","level":"info"}\n)
assert expected == to_string(:logger_formatter_json.format(%{level: :info, msg: {:string, "408µs\n"}, meta: %{}}, %{}))
end
end

describe "Structured log messages" do
Expand Down

0 comments on commit b8621a2

Please sign in to comment.