Package io.debezium.util
Class LoggingContext
java.lang.Object
io.debezium.util.LoggingContext
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
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
A snapshot of an MDC context that can beLoggingContext.PreviousContext.restore()
. -
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The key for the connector context name MDC property.static final String
The key for the connector logical name MDC property.static final String
The key for the connector type MDC property.static final String
The key for the database name MDC property.static final String
The key for the task id MDC property. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionforConnector
(String connectorType, String connectorName, String contextName) Configure for a connector the logger's Mapped Diagnostic Context (MDC) properties for the thread making this call.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.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.
-
Field Details
-
CONNECTOR_TYPE
The key for the connector type MDC property.- See Also:
-
CONNECTOR_NAME
The key for the connector logical name MDC property.- See Also:
-
CONNECTOR_CONTEXT
The key for the connector context name MDC property.- See Also:
-
TASK_ID
The key for the task id MDC property.- See Also:
-
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 nullconnectorName
- the name of the connector; may not be nullcontextName
- 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 nullconnectorName
- the name of the connector; may not be nulltaskId
- the task id; may be nullcontextName
- the name of the context; may not be nullpartition
- 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 nullconnectorName
- the logical name of the connector; may not be nullcontextName
- the name of the context; may not be nulloperation
- the function to run in the new MDC context; may not be null- Throws:
NullPointerException
- if any of the parameters are null
-