Skip to content

Commit 0310bd4

Browse files
author
Per Leino
committed
Make it configurable to end messages with CR LF for TCPSender
1 parent b680b9c commit 0310bd4

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/main/java/com/cloudbees/syslog/sender/TcpSyslogMessageSender.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ public class TcpSyslogMessageSender extends AbstractSyslogMessageSender {
7676
*/
7777
protected final AtomicInteger trySendErrorCounter = new AtomicInteger();
7878

79+
// use the CR LF non transparent framing as described in "3.4.2. Non-Transparent-Framing"
80+
private String postfix = "\r\n";
81+
7982
@Override
8083
public synchronized void sendMessage(@Nonnull SyslogMessage message) throws IOException {
8184
sendCounter.incrementAndGet();
@@ -90,8 +93,7 @@ public synchronized void sendMessage(@Nonnull SyslogMessage message) throws IOEx
9093
}
9194
ensureSyslogServerConnection();
9295
message.toSyslogMessage(messageFormat, writer);
93-
// use the CR LF non transparent framing as described in "3.4.2. Non-Transparent-Framing"
94-
writer.write("\r\n");
96+
writer.write(postfix);
9597
writer.flush();
9698
return;
9799
} catch (IOException e) {
@@ -240,6 +242,10 @@ public void setMaxRetryCount(int maxRetryCount) {
240242
this.maxRetryCount = maxRetryCount;
241243
}
242244

245+
public void setPostfix(String postfix) {
246+
this.postfix = postfix;
247+
}
248+
243249
@Override
244250
public String toString() {
245251
return getClass().getName() + "{" +

0 commit comments

Comments
 (0)