This commit is contained in:
Mark Nellemann 2020-12-15 10:29:54 +01:00
parent 259f90c86c
commit 7e8f49edbb
5 changed files with 10 additions and 14 deletions

View file

@ -12,9 +12,8 @@ repositories {
}
dependencies {
compile 'info.picocli:picocli:4.5.2'
annotationProcessor 'info.picocli:picocli-codegen:4.5.2'
implementation 'info.picocli:picocli:4.5.2'
implementation 'org.slf4j:slf4j-api:1.7.+'
runtimeOnly 'ch.qos.logback:logback-classic:1.+'
@ -23,7 +22,7 @@ dependencies {
}
application {
mainClassName = 'biz.nellemann.syslogd.SyslogServer'
mainClassName = 'biz.nellemann.syslogd.Application'
}
test {

View file

@ -1,3 +1,3 @@
id = syslogd
group = biz.nellemann.syslogd
version = 1.0.5
version = 1.0.6

View file

@ -27,9 +27,9 @@ import java.util.concurrent.Callable;
mixinStandardHelpOptions = true,
description = "Basic syslog server.",
versionProvider = biz.nellemann.syslogd.VersionProvider.class)
public class SyslogServer implements Callable<Integer>, LogListener {
public class Application implements Callable<Integer>, LogListener {
private final static Logger log = LoggerFactory.getLogger(SyslogServer.class);
private final static Logger log = LoggerFactory.getLogger(Application.class);
@CommandLine.Option(names = {"-p", "--port"}, description = "Listening port [default: 514].")
private int port = 514;
@ -48,7 +48,7 @@ public class SyslogServer implements Callable<Integer>, LogListener {
public static void main(String... args) {
int exitCode = new CommandLine(new SyslogServer()).execute(args);
int exitCode = new CommandLine(new Application()).execute(args);
System.exit(exitCode);
}

View file

@ -100,9 +100,8 @@ public class TcpServer {
private synchronized void sendEvent(String message) {
LogEvent event = new LogEvent( this, message );
Iterator<LogListener> listeners = eventListeners.iterator();
while( listeners.hasNext() ) {
listeners.next().onLogEvent( event );
for (LogListener eventListener : eventListeners) {
eventListener.onLogEvent(event);
}
}

View file

@ -20,7 +20,6 @@ import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class UdpServer extends Thread {
@ -57,9 +56,8 @@ public class UdpServer extends Thread {
private synchronized void sendEvent(String message) {
LogEvent event = new LogEvent( this, message);
Iterator<LogListener> listeners = eventListeners.iterator();
while( listeners.hasNext() ) {
listeners.next().onLogEvent( event );
for (LogListener eventListener : eventListeners) {
eventListener.onLogEvent(event);
}
}