Skip to content
This repository was archived by the owner on Sep 22, 2025. It is now read-only.

Commit a87707f

Browse files
author
Michael Edwards
committed
Streamable interface for SAX-style message rendering
1 parent 4745292 commit a87707f

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

layout/src/main/java/com/vlkan/log4j2/logstash/layout/resolver/MessageResolver.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.fasterxml.jackson.databind.JsonNode;
44
import com.fasterxml.jackson.core.JsonGenerator;
5+
import com.vlkan.log4j2.logstash.layout.util.Streamable;
56
import org.apache.commons.lang3.StringUtils;
67
import org.apache.logging.log4j.core.LogEvent;
78
import org.apache.logging.log4j.message.Message;
@@ -54,6 +55,10 @@ private String resolveText(Message message) {
5455
}
5556

5657
private void resolveJson(Message message, JsonGenerator jsonGenerator) throws IOException {
58+
if (message instanceof Streamable) {
59+
((Streamable) message).streamTo(jsonGenerator);
60+
return;
61+
}
5762

5863
// Check message type.
5964
if (!(message instanceof MultiformatMessage)) {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.vlkan.log4j2.logstash.layout.util;
2+
3+
import com.fasterxml.jackson.core.JsonGenerator;
4+
import java.io.IOException;
5+
6+
public interface Streamable {
7+
public abstract void streamTo(JsonGenerator stream) throws IOException;
8+
}

0 commit comments

Comments
 (0)