Skip to content

Commit

Permalink
Merge pull request #38 from herp-inc/mojibake
Browse files Browse the repository at this point in the history
Herp.Logger.ANSI.Coloring: JSONの文字化けを防ぐ
  • Loading branch information
fumieval authored Mar 27, 2023
2 parents 42b80e5 + 13b85c2 commit 0c5ddee
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Herp/Logger/ANSI/Coloring.hs
Original file line number Diff line number Diff line change
@@ -79,7 +79,7 @@ convertTransportInputToFormattedMessageANSI TransportInput{message, date, level,
{ outputOptionsIndentAmount = 2
, outputOptionsColorOptions = Just colorOpt
}
objStr = T.encodeUtf8 . pStringOpt opt . B.unpack $ enc
objStr = T.encodeUtf8 $ pStringOpt opt $ T.unpack $ T.decodeUtf8 enc
in case enc of
"{}" -> insertColorBarIndent level msg
_ -> insertColorBarIndent level $ msg <> "\n" <> insertIndent 2 objStr
2 changes: 1 addition & 1 deletion tests/stdout.hs
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ loggerLevelTest config = withLogger config $ \logger -> do
logM [ #alert, "lorem ipsum" ]
logM [ #emerg, "lorem ipsum" ]
let msg = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis tortor enim, facilisis vitae ex non, molestie fringilla dui. Duis porta neque risus, eu iaculis odio semper quis. Cras suscipit molestie lacus, ac fringilla nulla blandit quis. Maecenas feugiat erat neque, id mattis nibh elementum sed. Donec nec felis nisi. Cras facilisis dui imperdiet velit rhoncus lobortis. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Praesent eget lorem consequat, elementum sapien eu, rhoncus est. Etiam tincidunt leo nibh, a ullamcorper orci tincidunt id. Curabitur non dui ac ipsum eleifend iaculis ultrices at felis.\n\nAenean mauris metus, iaculis eget sagittis ut, fringilla nec nunc. Vivamus ante dolor, bibendum ut tellus gravida, ultricies bibendum mi. Morbi vel lectus pulvinar, accumsan leo eu, maximus ante. Morbi justo nisl, malesuada eu ex venenatis, bibendum aliquam arcu. In scelerisque elementum eros, id pretium libero eleifend ac. Quisque dictum, turpis a faucibus tempus, tellus leo ullamcorper libero, ac condimentum ex ante eu tortor. Sed sit amet dolor arcu."
logM [ #info, msg, "key" .= ("value" :: String) ]
logM [ #info, msg, "key" .= ("あのイーハトーヴォのすきとおった風😅" :: String) ]

main :: IO ()
main = bracket (LS.newStdoutLoggerSet 4096) LS.rmLoggerSet $ \loggerSet -> do

0 comments on commit 0c5ddee

Please sign in to comment.