Package io.servicetalk.log4j2.mdc.utils
Class LoggerStringWriter
- java.lang.Object
-
- io.servicetalk.log4j2.mdc.utils.LoggerStringWriter
-
public final class LoggerStringWriter extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Stringaccumulated()Get the accumulated content that has been logged.static voidassertContainsMdcPair(java.lang.String value, java.lang.String expectedLabel, java.lang.String expectedValue)Verify that an MDCexpectedLabel=expectedValuepair is present invalue.static voidremove()Remove the underlying in-memory log appender.static voidreset()Clear the content of theaccumulated().static java.lang.StringstableAccumulated(int totalWaitTimeMillis)Wait for theaccumulated()content to remain unchanged fordelayMillismilliseconds.static java.lang.StringstableAccumulated(int totalWaitTimeMillis, long sleepDurationMs)Wait for theaccumulated()content to remain unchanged forsleepDurationMsmilliseconds.
-
-
-
Method Detail
-
reset
public static void reset()
Clear the content of theaccumulated().
-
remove
public static void remove()
Remove the underlying in-memory log appender.
-
accumulated
public static java.lang.String accumulated()
Get the accumulated content that has been logged.- Returns:
- the accumulated content that has been logged.
-
stableAccumulated
public static java.lang.String stableAccumulated(int totalWaitTimeMillis) throws java.lang.InterruptedException, java.util.concurrent.TimeoutExceptionWait for theaccumulated()content to remain unchanged fordelayMillismilliseconds.- Parameters:
totalWaitTimeMillis- The amount of milliseconds to wait for theaccumulated()content to stabilize.- Returns:
- The accumulated content that has been logged.
- Throws:
java.lang.InterruptedException- If interrupted while waiting for log content to stabilize.java.util.concurrent.TimeoutException- If thetotalWaitTimeMillisduration has been exceeded and theaccumulated()has not yet stabilize.
-
stableAccumulated
public static java.lang.String stableAccumulated(int totalWaitTimeMillis, long sleepDurationMs) throws java.lang.InterruptedException, java.util.concurrent.TimeoutExceptionWait for theaccumulated()content to remain unchanged forsleepDurationMsmilliseconds.- Parameters:
totalWaitTimeMillis- The total amount of milliseconds to wait.sleepDurationMs- The amount of milliseconds to wait between checking ifaccumulated()has stabilize.- Returns:
- The accumulated content that has been logged.
- Throws:
java.lang.InterruptedException- If interrupted while waiting for log content to stabilize.java.util.concurrent.TimeoutException- If thetotalWaitTimeMillisduration has been exceeded and theaccumulated()has not yet stabilize.
-
assertContainsMdcPair
public static void assertContainsMdcPair(java.lang.String value, java.lang.String expectedLabel, java.lang.String expectedValue)Verify that an MDCexpectedLabel=expectedValuepair is present invalue.- Parameters:
value- The log line.expectedLabel- The MDC key.expectedValue- The MDC value.
-
-