Skip to content

Commit

Permalink
Change host name from cfe_16 to cfe-16 (#6)
Browse files Browse the repository at this point in the history
* Change hostname to cfe-16 from cfe_16

* Change host name in test comment
  • Loading branch information
51-code authored Jan 23, 2025
1 parent ec05970 commit 520aa3d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
8 changes: 5 additions & 3 deletions src/main/java/com/teragrep/cfe_16/Converter.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public class Converter {
private SDElement metadataSDE;
private SDElement headerSDE;

private final String hostName = "cfe-16";

public SyslogMessage httpToSyslog(HttpEventData httpEventData, HeaderInfo headerInfo) {

setEventSeverity();
Expand All @@ -87,7 +89,7 @@ public SyslogMessage httpToSyslog(HttpEventData httpEventData, HeaderInfo header
*/
LOGGER.debug("Creating new syslog message with timestamp");
syslogMessage = new SyslogMessage().withTimestamp(httpEventData.getTimeAsLong()).withSeverity(severity)
.withAppName("capsulated").withHostname("cfe_16").withFacility(facility).withSDElement(metadataSDE)
.withAppName("capsulated").withHostname(hostName).withFacility(facility).withSDElement(metadataSDE)
.withSDElement(headerSDE).withMsg(httpEventData.getEvent());

} else {
Expand All @@ -96,7 +98,7 @@ public SyslogMessage httpToSyslog(HttpEventData httpEventData, HeaderInfo header
* in the request.
*/
LOGGER.debug("Creating new syslog message without timestamp");
syslogMessage = new SyslogMessage().withSeverity(severity).withAppName("capsulated").withHostname("cfe_16")
syslogMessage = new SyslogMessage().withSeverity(severity).withAppName("capsulated").withHostname(hostName)
.withFacility(facility).withSDElement(metadataSDE).withSDElement(headerSDE)
.withMsg(httpEventData.getEvent());
}
Expand Down Expand Up @@ -157,7 +159,7 @@ public SyslogMessage getHeaderInfoSyslogMessage(HeaderInfo headerInfo) {

SyslogMessage syslogMessage = null;
setHeaderSDE(headerInfo);
syslogMessage = new SyslogMessage().withSeverity(severity).withAppName("capsulated").withHostname("cfe_16")
syslogMessage = new SyslogMessage().withSeverity(severity).withAppName("capsulated").withHostname(hostName)
.withFacility(facility).withSDElement(headerSDE);

return syslogMessage;
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/com/teragrep/cfe_16/ConverterTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,15 @@ public void initialize() {
metadataSDE3.addSDParam("time_source", eventData3.getTimeSource());

supposedSyslogMessage1 = new SyslogMessage().withTimestamp(eventData1.getTimeAsLong())
.withSeverity(supposedSeverity).withAppName("capsulated").withHostname("cfe_16")
.withSeverity(supposedSeverity).withAppName("capsulated").withHostname("cfe-16")
.withFacility(supposedFacility).withSDElement(metadataSDE1).withMsg(eventData1.getEvent());

supposedSyslogMessage2 = new SyslogMessage().withSeverity(supposedSeverity).withAppName("capsulated")
.withHostname("cfe_16").withFacility(supposedFacility).withSDElement(metadataSDE2)
.withHostname("cfe-16").withFacility(supposedFacility).withSDElement(metadataSDE2)
.withMsg(eventData2.getEvent());

supposedSyslogMessage3 = new SyslogMessage().withSeverity(supposedSeverity).withAppName("capsulated")
.withHostname("cfe_16").withFacility(supposedFacility).withSDElement(metadataSDE3)
.withHostname("cfe-16").withFacility(supposedFacility).withSDElement(metadataSDE3)
.withMsg(eventData3.getEvent());
HeaderInfo headerInfo = new HeaderInfo();

Expand Down Expand Up @@ -205,7 +205,7 @@ public void facilityTest() {
/*
* Compares the AppName and HostName from the supposed SyslogMessage and the
* SyslogMessage returned from Converter. AppName should be hardcoded to
* "capsulated" and HostName should be hardcoded to "cfe_16".
* "capsulated" and HostName should be hardcoded to "cfe-16".
*/
@Test
public void appNameAndHostNameTest() {
Expand Down

0 comments on commit 520aa3d

Please sign in to comment.