Deferred log action in server Logger middleware#7744
Conversation
8bb474b to
2756d16
Compare
| * val logger: Logger[IO] = ... | ||
| * val logF: IO[String => IO[Unit]] = | ||
| * ioLocal.get.map { ctx => | ||
| * { msg => logger.info("log msg and ctx: ...") } |
There was a problem hiding this comment.
String interpolating the values for the example fails doc generation on native and JS
JS and Native runtimes throw errors saying the values are undefined
69e12b6 to
ba5c29b
Compare
| * @param redactHeadersWhen Function to determine which headers should be redacted | ||
| * @param logAction The effectful log action that returns a logging function | ||
| */ | ||
| sealed abstract case class LoggerConfig[F[_]] private[middleware] ( |
There was a problem hiding this comment.
Would it be problematic to extend it in a binary-compatible way in the future?
Even though the case class is sealed.
https://mimalyzer.indoorvivants.com/comparison/a134a982-9f94-4f36-8d8f-7f7b05a0c270
There was a problem hiding this comment.
I've changed it to a sealed abstract class and mimalyzer seems happy. New version: https://mimalyzer.indoorvivants.com/comparison/e8f82479-11fd-4678-a1f3-adc8f92f3723
(Handy little tool, I hadn't come across it! Is there a way to validate that sort of thing via the sbt plugin?)
I am not sure if there is a simpler approach for extending these builders in a binary-compatible way and would be happy to simplify it
There was a problem hiding this comment.
Is there a way to validate that sort of thing via the sbt plugin?
Only making changes, committing them, likely creating a tag, and running mimaReportBinaryIssues, I'm afraid
I think sealed abstract class is good enough.
Built on the work of @iRevive in #7446 but adding an intermediate config builder object to keep compatibility
I hate naming things
XConfigbut what else is there? Please bikeshed awayI think you could make an argument that
withDeferredLogActionis not the best name as it isn't clear thatwithLogActionmay give unintuitive behaviour, perhaps that should bewithLogActionand awithSomethingLogActionindicates the non-deferred one