Class LoggingContext

java.lang.Object
io.debezium.util.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
  • Field Details

    • CONNECTOR_TYPE

      public static final String CONNECTOR_TYPE
      The key for the connector type MDC property.
      See Also:
    • CONNECTOR_NAME

      public static final String CONNECTOR_NAME
      The key for the connector logical name MDC property.
      See Also:
    • CONNECTOR_CONTEXT

      public static final String CONNECTOR_CONTEXT
      The key for the connector context name MDC property.
      See Also:
    • TASK_ID

      public static final String TASK_ID
      The key for the task id MDC property.
      See Also:
    • DATABASE_NAME

      public static final String DATABASE_NAME
      The key for the database name MDC property.
      See Also:
  • Constructor Details

    • LoggingContext

      private LoggingContext()
  • Method Details

    • 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