Skip to content

Commit db4684b

Browse files
akash-akyajosevalim
authored andcommitted
Fix logger truncate for multi-byte characters (#9767)
1 parent f3f65e4 commit db4684b

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

lib/logger/lib/logger/utils.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ defmodule Logger.Utils do
8181
end
8282

8383
defp fix_binary(<<h, t::binary>>, acc) do
84-
fix_binary(t, <<h, acc::binary>>)
84+
fix_binary(t, <<acc::binary, h>>)
8585
end
8686

8787
defp fix_binary(<<>>, _acc) do

lib/logger/test/logger/utils_test.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ defmodule Logger.UtilsTest do
2323
assert truncate("olá", 4) == "olá"
2424
assert truncate("ááááá:", 10) == ["ááááá", " (truncated)"]
2525
assert truncate("áááááá:", 10) == ["ááááá", " (truncated)"]
26+
assert truncate("𠜎𠜱𠝹𠱓", 15) == ["𠜎𠜱𠝹", " (truncated)"]
2627

2728
# Charlists
2829
assert truncate('olá', 2) == ['olá', " (truncated)"]

0 commit comments

Comments
 (0)