Skip to content

Commit 520aa3d

Browse files
authored
Change host name from cfe_16 to cfe-16 (#6)
* Change hostname to cfe-16 from cfe_16 * Change host name in test comment
1 parent ec05970 commit 520aa3d

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/main/java/com/teragrep/cfe_16/Converter.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ public class Converter {
7171
private SDElement metadataSDE;
7272
private SDElement headerSDE;
7373

74+
private final String hostName = "cfe-16";
75+
7476
public SyslogMessage httpToSyslog(HttpEventData httpEventData, HeaderInfo headerInfo) {
7577

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

9395
} else {
@@ -96,7 +98,7 @@ public SyslogMessage httpToSyslog(HttpEventData httpEventData, HeaderInfo header
9698
* in the request.
9799
*/
98100
LOGGER.debug("Creating new syslog message without timestamp");
99-
syslogMessage = new SyslogMessage().withSeverity(severity).withAppName("capsulated").withHostname("cfe_16")
101+
syslogMessage = new SyslogMessage().withSeverity(severity).withAppName("capsulated").withHostname(hostName)
100102
.withFacility(facility).withSDElement(metadataSDE).withSDElement(headerSDE)
101103
.withMsg(httpEventData.getEvent());
102104
}
@@ -157,7 +159,7 @@ public SyslogMessage getHeaderInfoSyslogMessage(HeaderInfo headerInfo) {
157159

158160
SyslogMessage syslogMessage = null;
159161
setHeaderSDE(headerInfo);
160-
syslogMessage = new SyslogMessage().withSeverity(severity).withAppName("capsulated").withHostname("cfe_16")
162+
syslogMessage = new SyslogMessage().withSeverity(severity).withAppName("capsulated").withHostname(hostName)
161163
.withFacility(facility).withSDElement(headerSDE);
162164

163165
return syslogMessage;

src/test/java/com/teragrep/cfe_16/ConverterTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,15 +152,15 @@ public void initialize() {
152152
metadataSDE3.addSDParam("time_source", eventData3.getTimeSource());
153153

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

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

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

@@ -205,7 +205,7 @@ public void facilityTest() {
205205
/*
206206
* Compares the AppName and HostName from the supposed SyslogMessage and the
207207
* SyslogMessage returned from Converter. AppName should be hardcoded to
208-
* "capsulated" and HostName should be hardcoded to "cfe_16".
208+
* "capsulated" and HostName should be hardcoded to "cfe-16".
209209
*/
210210
@Test
211211
public void appNameAndHostNameTest() {

0 commit comments

Comments
 (0)