Skip to content

Commit

Permalink
show mdc in ConsoleLogEventTestFormatter
Browse files Browse the repository at this point in the history
  • Loading branch information
jhannes committed May 21, 2024
1 parent ae1f05b commit 3d533a9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,17 @@ public ConsoleLogEventTestFormatter(Configuration configuration) {

@Override
public String apply(LogEvent e) {
return String.format("%s %s [%s] [%s] [%s]: %s\n",
return String.format("%s %s [%s] [%s] [%s]%s%s: %s\n",
format.underline("TEST(" + getTestName(e) + ")"),
e.getLocalTime(),
e.getThreadName(),
colorizedLevel(e),
format.bold(e.getLoggerName()),
e.getMessage(messageFormatter))
+ exceptionFormatter.format(e.getThrowable());
format.bold(logger(e)),
showMarkers && e.getMarker() != null ? " {" + e.getMarker().getName() + "}" : "",
e.getMdcString(mdcFilter),
e.getMessage(messageFormatter)
)
+ exceptionFormatter.format(e.getThrowable());
}

private String getTestName(LogEvent event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class ConsoleLogEventFormatter implements LogEventFormatter {
protected final ExceptionFormatter exceptionFormatter = new ExceptionFormatter();
protected final DateTimeFormatter timeOnlyFormatter = DateTimeFormatter.ofPattern("HH:mm:ss.SSS");
protected MdcFilter mdcFilter = MdcFilter.INCLUDE_ALL;
private boolean showMarkers = true;
protected boolean showMarkers = true;
private boolean multipleLines = false;
private List<String> logFilenameForPackages = new ArrayList<>();

Expand Down Expand Up @@ -83,7 +83,7 @@ public String apply(LogEvent e) {
}
}

private String logger(LogEvent e) {
protected String logger(LogEvent e) {
if (logFilenameForPackages.isEmpty()) {
return e.getLoggerName();
}
Expand Down

0 comments on commit 3d533a9

Please sign in to comment.