Skip to content

Commit

Permalink
Refactor syslog writer
Browse files Browse the repository at this point in the history
  • Loading branch information
pmwmedia committed Nov 17, 2023
1 parent 235ab62 commit ea4fb9c
Show file tree
Hide file tree
Showing 5 changed files with 215 additions and 171 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@
*/
public final class SyslogWriter extends AbstractFormatPatternWriter {

private AbstractSocketWriter socketWriter;
private final AbstractSocketWriter socketWriter;

/**
* @param properties
* Configuration for writer
*
* @throws IOException
* Socket cannot be opened for write access
* @throws IllegalArgumentException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public abstract class AbstractSocketWriter extends AbstractFormatPatternWriter {
private static final int DEFAULT_PORT_NUMBER = 514;
private static final String DEFAULT_FACILITY = "USER";
private static final int FACILITY_CODE_SHIFT = 3;
private static final String DEFAULT_SEVERITY = "INFO";
private static final String DEFAULT_SEVERITY = "INFORMATIONAL";

private final InetAddress inetAddress;
private final int port;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ public enum SyslogFacility {
/**
* Log audit.
*/
LOG_AUDIT(13),
SECURITY(13),

/**
* Log alert.
*/
LOG_ALERT(14),
CONSOLE(14),

/**
* Clock daemon.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
import org.tinylog.Level;

/**
* Syslog severity codes.
* Syslog severity levels.
*/
public enum SyslogSeverity {

/**
* System is unusable.
*/
EMERG(0),
EMERGENCY(0),
/**
* Action must be taken immediately.
*/
Expand All @@ -47,7 +47,7 @@ public enum SyslogSeverity {
/**
* Informational messages.
*/
INFO(6),
INFORMATIONAL(6),
/**
* Debug level messages.
*/
Expand All @@ -70,24 +70,23 @@ public int getCode() {
/**
* Returns the Severity for the specified Level.
* @param level The Level.
* @return The matching Severity, or INFO if there is no match.
* @return The matching Severity, or INFORMATIONAL if there is no match.
*/
public static SyslogSeverity getSeverity(final Level level) {
switch (level) {
case TRACE:
return DEBUG;
case DEBUG:
return DEBUG;
case INFO:
return INFO;
return INFORMATIONAL;
case WARN:
return WARNING;
case ERROR:
return ERROR;
case OFF:
return EMERG;
return EMERGENCY;
default:
return INFO;
return INFORMATIONAL;
}
}
}
Loading

0 comments on commit ea4fb9c

Please sign in to comment.