Add additional constructors for CapturedLogEvent (#26016)
As requested in PR #25907 - more constructors to cover more simple cases
This commit is contained in:
parent
a8d37f5d28
commit
5ccfc12eb5
2 changed files with 29 additions and 1 deletions
|
|
@ -31,6 +31,34 @@ final case class CapturedLogEvent(
|
|||
this(logLevel, message, errorCause.asScala, marker.asScala, mdc.asScala.toMap)
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for Java API
|
||||
*/
|
||||
def this(logLevel: LogLevel, message: String) {
|
||||
this(logLevel, message, Option.empty, Option.empty, Map.empty[String, Any])
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for Java API
|
||||
*/
|
||||
def this(logLevel: LogLevel, message: String, errorCause: Throwable) {
|
||||
this(logLevel, message, Some(errorCause), Option.empty[LogMarker], Map.empty[String, Any])
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for Java API
|
||||
*/
|
||||
def this(logLevel: LogLevel, message: String, marker: LogMarker) {
|
||||
this(logLevel, message, Option.empty[Throwable], Some(marker), Map.empty[String, Any])
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for Java API
|
||||
*/
|
||||
def this(logLevel: LogLevel, message: String, errorCause: Throwable, marker: LogMarker) {
|
||||
this(logLevel, message, Some(errorCause), Some(marker), Map.empty[String, Any])
|
||||
}
|
||||
|
||||
def getMdc: java.util.Map[String, Any] = mdc.asJava
|
||||
|
||||
def getErrorCause: Optional[Throwable] = cause.asJava
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ public class BehaviorTestKitTest extends JUnitSuite {
|
|||
test.run(new Log(what));
|
||||
final List<CapturedLogEvent> allLogEntries = test.getAllLogEntries();
|
||||
assertEquals(1, allLogEntries.size());
|
||||
assertEquals(new CapturedLogEvent(Logging.InfoLevel(), what, Optional.empty(), Optional.empty(), new HashMap<>()), allLogEntries.get(0));
|
||||
assertEquals(new CapturedLogEvent(Logging.InfoLevel(), what), allLogEntries.get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue