File tree Expand file tree Collapse file tree 3 files changed +30
-2
lines changed
java/me/itzg/helpers/logger Expand file tree Collapse file tree 3 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -87,6 +87,7 @@ dependencies {
8787 implementation ' ch.qos.logback:logback-core'
8888 implementation ' ch.qos.logback:logback-classic'
8989 implementation " info.picocli:picocli:${ picocliVersion} "
90+ implementation ' org.fusesource.jansi:jansi:2.4.0'
9091 implementation ' com.fasterxml.jackson.core:jackson-databind'
9192 implementation ' com.fasterxml.jackson.dataformat:jackson-dataformat-yaml'
9293 implementation ' com.fasterxml.jackson.dataformat:jackson-dataformat-xml'
Original file line number Diff line number Diff line change 1+ package me .itzg .helpers .logger ;
2+
3+ import ch .qos .logback .classic .Level ;
4+ import ch .qos .logback .classic .spi .ILoggingEvent ;
5+ import ch .qos .logback .core .pattern .color .ANSIConstants ;
6+ import ch .qos .logback .core .pattern .color .ForegroundCompositeConverterBase ;
7+
8+ public class CustomHighlight extends ForegroundCompositeConverterBase <ILoggingEvent > {
9+
10+ @ Override
11+ protected String getForegroundColorCode (ILoggingEvent event ) {
12+ Level level = event .getLevel ();
13+ switch (level .toInt ()) {
14+ case Level .ERROR_INT :
15+ return ANSIConstants .BOLD + ANSIConstants .RED_FG ; // same as default color scheme
16+ case Level .WARN_INT :
17+ return ANSIConstants .YELLOW_FG ;// same as default color scheme
18+ case Level .INFO_INT :
19+ default :
20+ return ANSIConstants .DEFAULT_FG ;
21+ }
22+ }
23+
24+ }
Original file line number Diff line number Diff line change 11<configuration >
2+ <conversionRule conversionWord =" customHighlight" converterClass =" me.itzg.helpers.logger.CustomHighlight" />
23 <appender name =" STDOUT" class =" ch.qos.logback.core.ConsoleAppender" >
4+ <withJansi >true</withJansi >
35 <filter class =" ch.qos.logback.classic.filter.LevelFilter" >
46 <level >INFO</level >
57 <onMatch >ACCEPT</onMatch >
810 <!-- encoders are assigned the type
911 ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
1012 <encoder >
11- <pattern >[mc-image-helper] %d{HH:mm:ss.SSS} %-5level : %msg%n</pattern >
13+ <pattern >%customHighlight( [mc-image-helper] %d{HH:mm:ss.SSS} %-5level : %msg%n) </pattern >
1214 </encoder >
1315 </appender >
1416 <appender name =" STDERR" class =" ch.qos.logback.core.ConsoleAppender" >
17+ <withJansi >true</withJansi >
1518 <filter class =" ch.qos.logback.classic.filter.LevelFilter" >
1619 <level >INFO</level >
1720 <onMatch >DENY</onMatch >
2124 <!-- encoders are assigned the type
2225 ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
2326 <encoder >
24- <pattern >[mc-image-helper] %d{HH:mm:ss.SSS} %-5level : %msg%n</pattern >
27+ <pattern >%customHighlight( [mc-image-helper] %d{HH:mm:ss.SSS} %-5level : %msg%n) </pattern >
2528 </encoder >
2629 </appender >
2730
You can’t perform that action at this time.
0 commit comments