Renamed frame header to octet counting as specified in RFC 6587. (#7)
* Renamed frame header to octet counting as specified in RFC 6587. * Introduced date argument in log method when structured message is sent as argument.
This commit is contained in:
parent
fdba539aa8
commit
9f2e804e9b
@ -44,6 +44,8 @@ public interface SyslogIF extends SyslogConstants {
|
|||||||
public void emergency(String message);
|
public void emergency(String message);
|
||||||
|
|
||||||
public void log(int level, SyslogMessageIF message);
|
public void log(int level, SyslogMessageIF message);
|
||||||
|
|
||||||
|
public void log(int level, SyslogMessageIF message, Date datetime);
|
||||||
|
|
||||||
public void debug(SyslogMessageIF message);
|
public void debug(SyslogMessageIF message);
|
||||||
|
|
||||||
|
@ -149,6 +149,20 @@ public abstract class AbstractSyslog implements SyslogIF {
|
|||||||
log(getMessageProcessor(), level, message.createMessage());
|
log(getMessageProcessor(), level, message.createMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void log(int level, SyslogMessageIF message, Date datetime) {
|
||||||
|
if (message instanceof StructuredSyslogMessageIF) {
|
||||||
|
if (getMessageProcessor() instanceof StructuredSyslogMessageProcessor) {
|
||||||
|
log(getMessageProcessor(), level, message.createMessage(), datetime);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
log(getStructuredMessageProcessor(), level, message.createMessage(), datetime);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
log(getMessageProcessor(), level, message.createMessage(), datetime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void debug(String message) {
|
public void debug(String message) {
|
||||||
log(LEVEL_DEBUG, message);
|
log(LEVEL_DEBUG, message);
|
||||||
|
@ -178,4 +178,8 @@ public class MultipleSyslog implements SyslogIF {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void log(int level, SyslogMessageIF message, Date datetime) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ public class TCPNetSyslogConfig extends AbstractNetSyslogConfig implements TCPNe
|
|||||||
* 89 <165>1 2003-10-11T22:14:15.003Z mymachine.example.com evntslog - ID47 [exampleSDID@32473]
|
* 89 <165>1 2003-10-11T22:14:15.003Z mymachine.example.com evntslog - ID47 [exampleSDID@32473]
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private boolean useFrameHeader;
|
private boolean useOctetCounting;
|
||||||
|
|
||||||
public TCPNetSyslogConfig() {
|
public TCPNetSyslogConfig() {
|
||||||
initialize();
|
initialize();
|
||||||
@ -161,12 +161,12 @@ public class TCPNetSyslogConfig extends AbstractNetSyslogConfig implements TCPNe
|
|||||||
this.freshConnectionInterval = freshConnectionInterval;
|
this.freshConnectionInterval = freshConnectionInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUseFrameHeader(boolean useFrameHeader) {
|
public void setUseOctetCounting(boolean useOctetCounting) {
|
||||||
this.useFrameHeader = useFrameHeader;
|
this.useOctetCounting = useOctetCounting;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUseFrameHeader() {
|
public boolean isUseOctetCounting() {
|
||||||
return this.useFrameHeader;
|
return this.useOctetCounting;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Class getSyslogWriterClass() {
|
public Class getSyslogWriterClass() {
|
||||||
|
@ -46,7 +46,7 @@ public interface TCPNetSyslogConfigIF extends AbstractNetSyslogConfigIF {
|
|||||||
|
|
||||||
public void setFreshConnectionInterval(int interval);
|
public void setFreshConnectionInterval(int interval);
|
||||||
|
|
||||||
public void setUseFrameHeader(boolean useFrameHeader);
|
public void setUseOctetCounting(boolean useFrameHeader);
|
||||||
|
|
||||||
public boolean isUseFrameHeader();
|
public boolean isUseOctetCounting();
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,7 @@ public class TCPNetSyslogWriter extends AbstractSyslogWriter {
|
|||||||
OutputStream os = currentSocket.getOutputStream();
|
OutputStream os = currentSocket.getOutputStream();
|
||||||
|
|
||||||
String frameHeader = "";
|
String frameHeader = "";
|
||||||
if(this.tcpNetSyslogConfig.isUseFrameHeader()){
|
if(this.tcpNetSyslogConfig.isUseOctetCounting()){
|
||||||
frameHeader = message.length + " ";
|
frameHeader = message.length + " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ public class TCPNetSyslogWriter extends AbstractSyslogWriter {
|
|||||||
os.write(frameHeader.getBytes());
|
os.write(frameHeader.getBytes());
|
||||||
os.write(message);
|
os.write(message);
|
||||||
|
|
||||||
if(!this.tcpNetSyslogConfig.isUseFrameHeader()) {
|
if(!this.tcpNetSyslogConfig.isUseOctetCounting()) {
|
||||||
byte[] delimiterSequence = this.tcpNetSyslogConfig.getDelimiterSequence();
|
byte[] delimiterSequence = this.tcpNetSyslogConfig.getDelimiterSequence();
|
||||||
if (delimiterSequence != null && delimiterSequence.length > 0) {
|
if (delimiterSequence != null && delimiterSequence.length > 0) {
|
||||||
os.write(delimiterSequence);
|
os.write(delimiterSequence);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user