Tagged Logger
This is a logging class to help apply and remove MDC context tags from within calls in service code.
In particular, it solves the problem with searching logs using the MDC context tags where an exception caught and thrown by misk doesn't include the MDC tags and doesn't show up in the search. Using this will mean exceptions will be visible in the sequence of logs relating to a tag. See the logging example below for usage and the logging output.
Usage:
First set up a logger class with relevant MDC functions for the code base:
class MyServiceLogger
// Create a global helper function to return the above class // Can be called from companion objects or regular classes - will find correct logger fun
Then to use the tagged logger for example:
class ServiceAction (private val webClient: WebClient): WebAction {