Skip to content

Commit 9dfb8cf

Browse files
refactoring
1 parent a289e4e commit 9dfb8cf

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

src/main/java/com/cloudbees/syslog/SyslogMessageFormat.java renamed to src/main/java/com/cloudbees/syslog/MessageFormat.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*
2121
* @author <a href="mailto:[email protected]">Cyrille Le Clerc</a>
2222
*/
23-
public enum SyslogMessageFormat {
23+
public enum MessageFormat {
2424
/**
2525
* <a href="http://tools.ietf.org/html/rfc3164">RFC 3614 - BSD syslog Protocol</a>
2626
*/

src/main/java/com/cloudbees/syslog/SyslogMessage.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333

3434
/**
3535
* Syslog message as defined in <a href="https://tools.ietf.org/html/rfc5424">RFC 5424 - The Syslog Protocol</a>.
36+
* <p/>
37+
* Also compatible with <a href="http://tools.ietf.org/html/rfc3164">RFC-3164: The BSD syslog Protocol</a>,
3638
*
3739
* @author <a href="mailto:[email protected]">Cyrille Le Clerc</a>
3840
*/
@@ -208,36 +210,36 @@ public SyslogMessage withMsg(final String msg) {
208210
* Generates a Syslog message complying to the <a href="http://tools.ietf.org/html/rfc5424">RFC-5424</a> format
209211
* or to the <a href="http://tools.ietf.org/html/rfc3164">RFC-3164</a> format.
210212
*
211-
* @param syslogMessageFormat message format, not {@code null}
213+
* @param messageFormat message format, not {@code null}
212214
*/
213-
public String toSyslogMessage(SyslogMessageFormat syslogMessageFormat) {
214-
switch (syslogMessageFormat) {
215+
public String toSyslogMessage(MessageFormat messageFormat) {
216+
switch (messageFormat) {
215217
case RFC_3164:
216218
return toRfc3164SyslogMessage();
217219
case RFC_5424:
218220
return toRfc5424SyslogMessage();
219221
default:
220-
throw new IllegalStateException("Unsupported message format '" + syslogMessageFormat + "'");
222+
throw new IllegalStateException("Unsupported message format '" + messageFormat + "'");
221223
}
222224
}
223225

224226
/**
225227
* Generates a Syslog message complying to the <a href="http://tools.ietf.org/html/rfc5424">RFC-5424</a> format
226228
* or to the <a href="http://tools.ietf.org/html/rfc3164">RFC-3164</a> format.
227229
*
228-
* @param syslogMessageFormat message format
230+
* @param messageFormat message format
229231
* @param out output {@linkplain Writer}
230232
*/
231-
public void toSyslogMessage(@Nonnull SyslogMessageFormat syslogMessageFormat, @Nonnull Writer out) throws IOException {
232-
switch (syslogMessageFormat) {
233+
public void toSyslogMessage(@Nonnull MessageFormat messageFormat, @Nonnull Writer out) throws IOException {
234+
switch (messageFormat) {
233235
case RFC_3164:
234236
toRfc3164SyslogMessage(out);
235237
break;
236238
case RFC_5424:
237239
toRfc5424SyslogMessage(out);
238240
break;
239241
default:
240-
throw new IllegalStateException("Unsupported message format '" + syslogMessageFormat + "'");
242+
throw new IllegalStateException("Unsupported message format '" + messageFormat + "'");
241243
}
242244
}
243245

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33
import com.cloudbees.syslog.Facility;
44
import com.cloudbees.syslog.Severity;
55
import com.cloudbees.syslog.SyslogMessage;
6-
import com.cloudbees.syslog.SyslogMessageFormat;
7-
import com.cloudbees.syslog.util.CachingReference;
6+
import com.cloudbees.syslog.MessageFormat;
87

98
import javax.annotation.Nonnull;
109
import java.io.CharArrayWriter;
1110
import java.io.IOException;
12-
import java.net.InetAddress;
1311
import java.nio.charset.Charset;
1412
import java.util.concurrent.TimeUnit;
1513
import java.util.concurrent.atomic.AtomicInteger;
@@ -30,10 +28,10 @@ public abstract class AbstractSyslogMessageSender implements SyslogMessageSender
3028
// remote syslog server config
3129
/**
3230
* Format of messages accepted by the remote syslog server
33-
* ({@link com.cloudbees.syslog.SyslogMessageFormat#RFC_3164 RFC_3164} or
34-
* {@link com.cloudbees.syslog.SyslogMessageFormat#RFC_5424 RFC_5424})
31+
* ({@link com.cloudbees.syslog.MessageFormat#RFC_3164 RFC_3164} or
32+
* {@link com.cloudbees.syslog.MessageFormat#RFC_5424 RFC_5424})
3533
*/
36-
protected SyslogMessageFormat messageFormat = DEFAULT_SYSLOG_MESSAGE_FORMAT;
34+
protected MessageFormat messageFormat = DEFAULT_SYSLOG_MESSAGE_FORMAT;
3735
// statistics
3836
protected final AtomicInteger sendCounter = new AtomicInteger();
3937
protected final AtomicLong sendDurationInNanosCounter = new AtomicLong();
@@ -81,7 +79,7 @@ public Facility getDefaultFacility() {
8179
return defaultFacility;
8280
}
8381

84-
public SyslogMessageFormat getMessageFormat() {
82+
public MessageFormat getMessageFormat() {
8583
return messageFormat;
8684
}
8785

@@ -131,8 +129,8 @@ public void setDefaultFacility(Facility defaultFacility) {
131129
this.defaultFacility = defaultFacility;
132130
}
133131

134-
public void setMessageFormat(SyslogMessageFormat syslogMessageFormat) {
135-
this.messageFormat = syslogMessageFormat;
132+
public void setMessageFormat(MessageFormat messageFormat) {
133+
this.messageFormat = messageFormat;
136134
}
137135

138136
public void setDefaultSeverity(Severity defaultSeverity) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
package com.cloudbees.syslog.sender;
1717

1818
import com.cloudbees.syslog.SyslogMessage;
19-
import com.cloudbees.syslog.SyslogMessageFormat;
19+
import com.cloudbees.syslog.MessageFormat;
2020

2121
import javax.annotation.Nonnull;
2222
import javax.annotation.Nullable;
@@ -31,7 +31,7 @@ public interface SyslogMessageSender {
3131
public static final long DEFAULT_INET_ADDRESS_TTL_IN_MILLIS = TimeUnit.MILLISECONDS.convert(30, TimeUnit.SECONDS);
3232
public static final long DEFAULT_INET_ADDRESS_TTL_IN_NANOS = TimeUnit.NANOSECONDS.convert(DEFAULT_INET_ADDRESS_TTL_IN_MILLIS, TimeUnit.MILLISECONDS);
3333
public static final String DEFAULT_SYSLOG_HOST = "localhost";
34-
public static final SyslogMessageFormat DEFAULT_SYSLOG_MESSAGE_FORMAT = SyslogMessageFormat.RFC_3164;
34+
public static final MessageFormat DEFAULT_SYSLOG_MESSAGE_FORMAT = MessageFormat.RFC_3164;
3535
public static final int DEFAULT_SYSLOG_PORT = 514;
3636

3737
/**

0 commit comments

Comments
 (0)