Closed chrisdone closed 4 years ago
Some high level thoughts:
Disadvantage: it throws an obstacle in the face of new users about which logging system to use (docs may help there)
I can definitely push a commit to address this more explicitly in docs.
I've updated the commentary, but I haven't experimented with an associated type instead of the fundep yet.
Hurrah, passing tests. Merging! :tada:
This PR adds generic logging to RIO such that you can log any data type rather than just
Utf8Builder
, and you don't have to decide what log level or format your logs are going to be until later. This is not intended as a replacement for RIO's existing logger, but rather allows different backends to be used, including the "classic" logger.Many apps I write might want to log in different ways with non trivial filtering of the logs, with sublogging, and I don't necessarily know right away what levels my logs should be at the call site (it might depend on context). Going through a data type isn't necessarily as fast as going straight to
Utf8Builder
, but that's a conscious trade-off. Idiom is an example of such an app that is using this.(Aside: This PR isn't meant to address various perf. improvement techniques, but if you are really suffering from log speeds and still want to use a generic data type, you have the option to use a newtype wrapper around
Utf8Builder
, andPatternSynonyms
which immediately render to theUtf8Builder
. This would be an advanced case. Alternatively, you could experiment withINLINE
with the intention of having the compiler bypass allocation of the constructor altogether.)Example:
Example output: