Add usage help to README.
This commit is contained in:
parent
4106453a68
commit
a1599d0862
10
README.md
10
README.md
|
@ -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.
|
- 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 :)
|
- 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.
|
||||||
|
````
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package biz.nellemann.syslogd;
|
package biz.nellemann.syslogd;
|
||||||
|
|
||||||
public enum Color {
|
public enum Ansi {
|
||||||
//Color end string, color reset
|
//Color end string, color reset
|
||||||
RESET("\033[0m"),
|
RESET("\033[0m"),
|
||||||
|
CLEAR_LINE("\033[0K"),
|
||||||
|
|
||||||
// Regular Colors. Normal color, no bold, background color etc.
|
// Regular Colors. Normal color, no bold, background color etc.
|
||||||
BLACK("\033[0;30m"), // BLACK
|
BLACK("\033[0;30m"), // BLACK
|
||||||
|
@ -76,7 +77,7 @@ public enum Color {
|
||||||
|
|
||||||
private final String code;
|
private final String code;
|
||||||
|
|
||||||
Color(String code) {
|
Ansi(String code) {
|
||||||
this.code = code;
|
this.code = code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,20 +52,20 @@ public class SyslogMessage {
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
sb.append(Color.WHITE); sb.append(timestamp.toString() + " "); sb.append(Color.RESET);
|
sb.append(timestamp.toString() + " ");
|
||||||
|
|
||||||
if(severity.toNumber() < 3 ) {
|
if(severity.toNumber() < 3 ) {
|
||||||
sb.append(Color.RED);
|
sb.append(Ansi.RED);
|
||||||
} else if(severity.toNumber() < 5) {
|
} else if(severity.toNumber() < 5) {
|
||||||
sb.append(Color.YELLOW);
|
sb.append(Ansi.YELLOW);
|
||||||
} else {
|
} 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(Ansi.BLUE); sb.append("\t" + hostname); sb.append(Ansi.RESET);
|
||||||
sb.append(Color.CYAN); sb.append("\t" + application); sb.append(Color.RESET);
|
sb.append(Ansi.CYAN); sb.append("\t" + application); sb.append(Ansi.RESET);
|
||||||
sb.append("\t" + message);
|
sb.append("\t" + message); sb.append(Ansi.CLEAR_LINE);
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ class SyslogParserTest extends Specification {
|
||||||
msg.message == "adfdfdf3432434565656"
|
msg.message == "adfdfdf3432434565656"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void "test rfc3164 aix/vios message"() {
|
void "test rfc3164 aix/vios message"() {
|
||||||
|
|
||||||
setup:
|
setup:
|
||||||
|
|
Loading…
Reference in a new issue