mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-01-20 09:17:29 +07:00
Implemented basic MDC encoding
This commit is contained in:
parent
290160d93d
commit
ddae4b9f75
@ -1,6 +1,7 @@
|
||||
package com.riiablo.logger;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import org.apache.commons.collections4.OrderedMap;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
|
||||
public class RiiabloEncoder extends SimpleEncoder {
|
||||
@ -9,7 +10,9 @@ public class RiiabloEncoder extends SimpleEncoder {
|
||||
@Override
|
||||
public void encode(LogEvent event, OutputStream out) {
|
||||
try {
|
||||
final OrderedMap<String, String> mdc = event.mdc();
|
||||
encodeMessage(event, buffer);
|
||||
encodeMDC(mdc, buffer);
|
||||
out.write(buffer.toString().getBytes(US_ASCII));
|
||||
newLine(out);
|
||||
} catch (Throwable t) {
|
||||
@ -18,4 +21,10 @@ public class RiiabloEncoder extends SimpleEncoder {
|
||||
buffer.setLength(0);
|
||||
}
|
||||
}
|
||||
|
||||
private void encodeMDC(OrderedMap<String, String> mdc, StringBuilder buffer) {
|
||||
if (mdc.isEmpty()) return;
|
||||
buffer.append(' ');
|
||||
buffer.append(mdc.toString());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user