I'm using the RIO monad and RIO libraries and want to add logging. The RIO log functions, like logInfo
, take a Utf8Builder
as parameter, which is a wrapper around a ByteString
builder. I would like to efficiently insert log statements in my code. However, I am not sure how to transform simple Text
, String
and ByteString
values into the appropriate Builder.
This does not type-check:
logInfo $ "Identifier: " <> UUID.toByteString myId
where myId
is a UUID
value. The type checker error is
• Couldn't match expected type ‘Utf8Builder’
with actual type ‘bytestring-0.10.10.0:Data.ByteString.Lazy.Internal.ByteString’
I tried converting the UUID into Text
instead, tried to use encodeUtf8Builder
and then wrap the resulting Builder
in an Utf8Builder
, but to no avail.
My gut feeling says that logging should simply work, without lots of conversions; so I am probably missing the obvious route. How can I simply log values using the RIO logger?