Class LoggingContext


  • public class LoggingContext
    extends Object
    A utility that provides a consistent set of properties for the Mapped Diagnostic Context (MDC) properties used by Debezium components.
    Since:
    0.2
    Author:
    Randall Hauch
    • Constructor Detail

      • LoggingContext

        private LoggingContext()
    • Method Detail

      • forConnector

        public static LoggingContext.PreviousContext forConnector​(String connectorType,
                                                                  String connectorName,
                                                                  String contextName)
        Configure for a connector the logger's Mapped Diagnostic Context (MDC) properties for the thread making this call.
        Parameters:
        connectorType - the type of connector; may not be null
        connectorName - the name of the connector; may not be null
        contextName - the name of the context; may not be null
        Returns:
        the previous MDC context; never null
        Throws:
        NullPointerException - if any of the parameters are null
      • forConnector

        public static LoggingContext.PreviousContext forConnector​(String connectorType,
                                                                  String connectorName,
                                                                  String taskId,
                                                                  String contextName,
                                                                  Partition partition)
        Configure for a connector the logger's Mapped Diagnostic Context (MDC) properties for the thread making this call.
        Parameters:
        connectorType - the type of connector; may not be null
        connectorName - the name of the connector; may not be null
        taskId - the task id; may be null
        contextName - the name of the context; may not be null
        partition - the partition; may be null
        Returns:
        the previous MDC context; never null
        Throws:
        NullPointerException - if connectorType, connectorName, or contextName parameters are null
      • temporarilyForConnector

        public static void temporarilyForConnector​(String connectorType,
                                                   String connectorName,
                                                   String contextName,
                                                   Runnable operation)
        Run the supplied function in the temporary connector MDC context, and when complete always return the MDC context to its state before this method was called.
        Parameters:
        connectorType - the type of connector; may not be null
        connectorName - the logical name of the connector; may not be null
        contextName - the name of the context; may not be null
        operation - the function to run in the new MDC context; may not be null
        Throws:
        NullPointerException - if any of the parameters are null