Remove coloring of log.info messages (#851)

This commit is contained in:
phytohydra 2024-03-29 10:47:59 +00:00 committed by GitHub
parent bc71d28598
commit b0b5fde742
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 40 additions and 1 deletions

View file

@ -0,0 +1,36 @@
/* Derived from https://logback.qos.ch/xref/ch/qos/logback/classic/pattern/color/HighlightingCompositeConverter.html */
package haveno.common.app;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.spi.ILoggingEvent;
import static ch.qos.logback.core.pattern.color.ANSIConstants.BOLD;
import static ch.qos.logback.core.pattern.color.ANSIConstants.DEFAULT_FG;
import static ch.qos.logback.core.pattern.color.ANSIConstants.RED_FG;
import ch.qos.logback.core.pattern.color.ForegroundCompositeConverterBase;
/**
* Highlights inner-text depending on the level, in bold red for events of level
* ERROR, in red for WARN, in the default color for INFO, and in the default color for other
* levels.
*/
public class LogHighlighter extends ForegroundCompositeConverterBase<ILoggingEvent> {
@Override
protected String getForegroundColorCode(ILoggingEvent event) {
Level level = event.getLevel();
switch (level.toInt()) {
case Level.ERROR_INT:
return BOLD + RED_FG;
case Level.WARN_INT:
return RED_FG;
case Level.INFO_INT:
return DEFAULT_FG;
default:
return DEFAULT_FG;
}
}
}

View file

@ -1,8 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<configuration> <configuration>
<conversionRule conversionWord="hl2" converterClass="haveno.common.app.LogHighlighter" />
<appender name="CONSOLE_APPENDER" class="ch.qos.logback.core.ConsoleAppender"> <appender name="CONSOLE_APPENDER" class="ch.qos.logback.core.ConsoleAppender">
<encoder> <encoder>
<pattern>%highlight(%d{MMM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{30}: %msg %xEx%n)</pattern> <pattern>%hl2(%d{MMM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{30}: %msg %xEx%n)</pattern>
</encoder> </encoder>
</appender> </appender>