How to use TimedFastLogger with structured logging?
Opened this issue · 0 comments
saurabhnanda commented
I'm trying to emit JSON logs from my app using a TimedFastLogger
. The function that I want to write, looks something like this:
logStructuredPayload :: FormattedTime -> StructuredPayload -> IO ()
internally this will convert StructuredPayload
to an Aeson.Encoding
that needs to contain the timestamp within the json log itself. Something like:
{
"@timestamp": "...",
"level": "...",
"sql_count": "...",
"sql_time": "....",
"api_count": "...",
"api_time": "..."
}
However, I'm not sure if something like this is possible, given the type-signature of TimedFastLogger
:
type TimedFastLogger = (FormattedTime -> LogStr) -> IO ()
I guess, a related question would be how to actually use LogCallback :: (v -> IO()) -> IO () -> LogType' v
? This is the only LogType'
which seems to be operating with something other than a LogStr
. Is the purpose of LogCallback
to be able to log values of type other than LogStr
?