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.String
accumulated()
Get the accumulated content that has been logged.static void
assertContainsMdcPair(java.lang.String value, java.lang.String expectedLabel, java.lang.String expectedValue)
Verify that an MDCexpectedLabel=expectedValue
pair is present invalue
.static void
remove()
Remove the underlying in-memory log appender.static void
reset()
Clear the content of theaccumulated()
.static java.lang.String
stableAccumulated(int totalWaitTimeMillis)
Wait for theaccumulated()
content to remain unchanged fordelayMillis
milliseconds.static java.lang.String
stableAccumulated(int totalWaitTimeMillis, long sleepDurationMs)
Wait for theaccumulated()
content to remain unchanged forsleepDurationMs
milliseconds.
-
-
-
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.TimeoutException
Wait for theaccumulated()
content to remain unchanged fordelayMillis
milliseconds.- 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 thetotalWaitTimeMillis
duration 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.TimeoutException
Wait for theaccumulated()
content to remain unchanged forsleepDurationMs
milliseconds.- 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 thetotalWaitTimeMillis
duration 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=expectedValue
pair is present invalue
.- Parameters:
value
- The log line.expectedLabel
- The MDC key.expectedValue
- The MDC value.
-
-