Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
logback-classic/src/main/java/ch/qos/logback/classic/pattern/PrefixCompositeConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package ch.qos.logback.classic.pattern; | ||
|
||
import static ch.qos.logback.core.util.OptionHelper.extractDefaultReplacement; | ||
|
||
import ch.qos.logback.classic.spi.ILoggingEvent; | ||
import ch.qos.logback.core.pattern.CompositeConverter; | ||
import ch.qos.logback.core.pattern.Converter; | ||
|
||
public class PrefixCompositeConverter extends CompositeConverter<ILoggingEvent> { | ||
|
||
public String convert(ILoggingEvent event) { | ||
StringBuilder buf = new StringBuilder(); | ||
Converter<ILoggingEvent> childConverter = this.getChildConverter(); | ||
|
||
for (Converter<ILoggingEvent> c = childConverter; c != null; c = c.getNext()) { | ||
if (c instanceof MDCConverter) { | ||
MDCConverter mdcConverter = (MDCConverter) c; | ||
|
||
String firstOption = mdcConverter.getFirstOption(); | ||
String[] keyInfo = extractDefaultReplacement(firstOption); | ||
String key = keyInfo[0]; | ||
if (key != null) { | ||
buf.append(key).append("="); | ||
} | ||
} else { | ||
|
||
} | ||
c.write(buf, event); | ||
} | ||
String intermediary = buf.toString(); | ||
|
||
return null; | ||
} | ||
|
||
protected String transform(ILoggingEvent event, String in) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
} |