Add usage help to README.

This commit is contained in:
Mark Nellemann 2020-09-23 14:43:40 +02:00
parent 4106453a68
commit a1599d0862
4 changed files with 21 additions and 11 deletions

View file

@ -9,3 +9,13 @@ The syslog server is able to listen on UDP and/or TCP and parses syslog messages
- Install the syslogd package (*.deb* or *.rpm*) from [downloads](https://bitbucket.org/mnellemann/syslogd/downloads/) or compile from source.
- Run *bin/syslogd*, use the *-h* option for help :)
````
Usage: syslogd [-hV] [--[no-]tcp] [--[no-]udp] [--rfc3164] [-p=<port>]
Simple syslog server that prints messages to stdout.
-h, --help Show this help message and exit.
--[no-]tcp Listen on TCP, true by default.
--[no-]udp Listen on UDP, true by default.
-p, --port=<port> Listening port, 514 (privileged) by default.
--rfc3164 Parse RFC3164 syslog message, RFC5424 by default.
-V, --version Print version information and exit.
````

View file

@ -1,8 +1,9 @@
package biz.nellemann.syslogd;
public enum Color {
public enum Ansi {
//Color end string, color reset
RESET("\033[0m"),
CLEAR_LINE("\033[0K"),
// Regular Colors. Normal color, no bold, background color etc.
BLACK("\033[0;30m"), // BLACK
@ -76,7 +77,7 @@ public enum Color {
private final String code;
Color(String code) {
Ansi(String code) {
this.code = code;
}

View file

@ -52,20 +52,20 @@ public class SyslogMessage {
StringBuilder sb = new StringBuilder();
sb.append(Color.WHITE); sb.append(timestamp.toString() + " "); sb.append(Color.RESET);
sb.append(timestamp.toString() + " ");
if(severity.toNumber() < 3 ) {
sb.append(Color.RED);
sb.append(Ansi.RED);
} else if(severity.toNumber() < 5) {
sb.append(Color.YELLOW);
sb.append(Ansi.YELLOW);
} else {
sb.append(Color.GREEN);
sb.append(Ansi.GREEN);
}
sb.append("[" + facility + "." + severity + "]"); sb.append(Color.RESET);
sb.append("[" + facility + "." + severity + "]"); sb.append(Ansi.RESET);
sb.append(Color.BLUE); sb.append("\t" + hostname); sb.append(Color.RESET);
sb.append(Color.CYAN); sb.append("\t" + application); sb.append(Color.RESET);
sb.append("\t" + message);
sb.append(Ansi.BLUE); sb.append("\t" + hostname); sb.append(Ansi.RESET);
sb.append(Ansi.CYAN); sb.append("\t" + application); sb.append(Ansi.RESET);
sb.append("\t" + message); sb.append(Ansi.CLEAR_LINE);
return sb.toString();
}

View file

@ -18,7 +18,6 @@ class SyslogParserTest extends Specification {
msg.message == "adfdfdf3432434565656"
}
void "test rfc3164 aix/vios message"() {
setup: