logging icon indicating copy to clipboard operation
logging copied to clipboard

Adding `setLogFormatter`

Open runeksvendsen opened this issue 6 years ago • 2 comments

Firstly, thanks for creating this library! I really appreciate having a simple logging library for getting stuff up and running quickly.

I'm in a situation where I need to log my messages in JSON format.

Would you accept a patch that adds a setLogFormatter function to this library, which takes as argument a function that is used to format log messages? This would enable the user to supply a function that returns the log message that's ultimately printed via System.Log.FastLogger.pushLogStr.

I figure its type signature would be something along the lines of:

setLogFormatter :: (UTCTime -> LogLevel -> LogSource -> logMsg -> Text) -> IO ()

Do you foresee any challenges regarding this? Also, do you have any requirements regarding the implementation of this, in order for a PR to be accepted by you?

Cheers :)

runeksvendsen avatar Sep 23 '19 14:09 runeksvendsen

Sounds like a good idea to me, and within the scope of what this library aims to provide. I can't think of any stringent requirements offhand.

jwiegley avatar Sep 24 '19 11:09 jwiegley

I've found an alternative to JSON logging, so I no longer have the motivation to implement this. But perhaps it makes sense to keep this issue open, in case someone else feels like writing the code?

runeksvendsen avatar Sep 26 '19 17:09 runeksvendsen