Package io.debezium.util
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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLoggingContext.PreviousContextA snapshot of an MDC context that can beLoggingContext.PreviousContext.restore().
-
Field Summary
Fields Modifier and Type Field Description static StringCONNECTOR_CONTEXTThe key for the connector context name MDC property.static StringCONNECTOR_NAMEThe key for the connector logical name MDC property.static StringCONNECTOR_TYPEThe key for the connector type MDC property.
-
Constructor Summary
Constructors Modifier Constructor Description privateLoggingContext()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static LoggingContext.PreviousContextforConnector(String connectorType, String connectorName, String contextName)Configure for a connector the logger's Mapped Diagnostic Context (MDC) properties for the thread making this call.static voidtemporarilyForConnector(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 Detail
-
CONNECTOR_TYPE
public static final String CONNECTOR_TYPE
The key for the connector type MDC property.- See Also:
- Constant Field Values
-
CONNECTOR_NAME
public static final String CONNECTOR_NAME
The key for the connector logical name MDC property.- See Also:
- Constant Field Values
-
CONNECTOR_CONTEXT
public static final String CONNECTOR_CONTEXT
The key for the connector context name MDC property.- See Also:
- Constant Field Values
-
-
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 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:
IllegalArgumentException- if any of the 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:
IllegalArgumentException- if any of the parameters are null
-
-