From f8656569918cffe8312673b8b242e29c88ee92c4 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 9 Nov 2014 19:47:11 -0800 Subject: [PATCH] GUAC-911: Add and document log level option for guacd. --- src/guacd/conf-args.c | 18 +++++++++++++++++- src/guacd/man/guacd.8 | 14 ++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/guacd/conf-args.c b/src/guacd/conf-args.c index 1b9382a6..51199f28 100644 --- a/src/guacd/conf-args.c +++ b/src/guacd/conf-args.c @@ -24,6 +24,7 @@ #include "conf-args.h" #include "conf-file.h" +#include "conf-parse.h" #include #include @@ -34,7 +35,7 @@ int guacd_conf_parse_args(guacd_config* config, int argc, char** argv) { /* Parse arguments */ int opt; - while ((opt = getopt(argc, argv, "l:b:p:C:K:f")) != -1) { + while ((opt = getopt(argc, argv, "l:b:p:L:C:K:f")) != -1) { /* -l: Bind port */ if (opt == 'l') { @@ -59,6 +60,20 @@ int guacd_conf_parse_args(guacd_config* config, int argc, char** argv) { config->pidfile = strdup(optarg); } + /* -L: Log level */ + else if (opt == 'L') { + + /* Validate and parse log level */ + int level = guacd_parse_log_level(optarg); + if (level == -1) { + fprintf(stderr, "Invalid log level. Valid levels are: \"debug\", \"info\", \"warning\", and \"error\".\n"); + return 1; + } + + config->max_log_level = level; + + } + #ifdef ENABLE_SSL /* -C SSL certificate */ else if (opt == 'C') { @@ -88,6 +103,7 @@ int guacd_conf_parse_args(guacd_config* config, int argc, char** argv) { " [-l LISTENPORT]" " [-b LISTENADDRESS]" " [-p PIDFILE]" + " [-L LEVEL]" #ifdef ENABLE_SSL " [-C CERTIFICATE_FILE]" " [-K PEM_FILE]" diff --git a/src/guacd/man/guacd.8 b/src/guacd/man/guacd.8 index bb5f3703..197e71f9 100644 --- a/src/guacd/man/guacd.8 +++ b/src/guacd/man/guacd.8 @@ -8,6 +8,7 @@ guacd \- Guacamole proxy daemon [\fB-b\fR \fIHOST\fR] [\fB-l\fR \fIPORT\fR] [\fB-p\fR \fIPID FILE\fR] +[\fB-L\fR \fILOG LEVEL\fR] [\fB-C\fR \fICERTIFICATE FILE\fR] [\fB-K\fR \fIKEY FILE\fR] [\fB-f\fR] @@ -42,6 +43,19 @@ to write the PID of the daemon process to the specified file. This is useful for init scripts and is used by the provided init script. .TP +\fB\-L\fR \fILEVEL\fR +Sets the maximum level at which +.B guacd +will log messages to syslog and, if running in the foreground, the console. +Legal values are +.B debug, +.B info, +.B warning, +and +.B error. +The default value is +.B info. +.TP \fB\-f\fR Causes .B guacd