From 049c366b78c6ccb58adc902db56fd0a3168614eb Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 9 Nov 2014 16:56:04 -0800 Subject: [PATCH] GUAC-911: Add config file option for log levels. --- src/guacd/conf-file.c | 27 +++++++++++++++++++++++++++ src/guacd/conf-file.h | 7 +++++++ src/guacd/man/guacd.conf.5 | 13 +++++++++++++ 3 files changed, 47 insertions(+) diff --git a/src/guacd/conf-file.c b/src/guacd/conf-file.c index e21552e1..15118ef8 100644 --- a/src/guacd/conf-file.c +++ b/src/guacd/conf-file.c @@ -25,6 +25,8 @@ #include "conf-file.h" #include "conf-parse.h" +#include + #include #include #include @@ -72,6 +74,30 @@ static int guacd_conf_callback(const char* section, const char* param, const cha return 0; } + /* Max log level */ + else if (strcmp(param, "log_level") == 0) { + + /* Translate level name */ + if (strcmp(value, "info") == 0) + config->max_log_level = GUAC_LOG_INFO; + else if (strcmp(value, "error") == 0) + config->max_log_level = GUAC_LOG_ERROR; + else if (strcmp(value, "warning") == 0) + config->max_log_level = GUAC_LOG_WARNING; + else if (strcmp(value, "debug") == 0) + config->max_log_level = GUAC_LOG_DEBUG; + + /* Invalid log level */ + else { + guacd_conf_parse_error = "Invalid log level. Valid levels are: \"debug\", \"info\", \"warning\", and \"error\"."; + return 1; + } + + /* Valid log level */ + return 0; + + } + } /* SSL-specific options */ @@ -163,6 +189,7 @@ guacd_config* guacd_conf_load() { conf->bind_port = strdup("4822"); conf->pidfile = NULL; conf->foreground = 0; + conf->max_log_level = GUAC_LOG_INFO; #ifdef ENABLE_SSL conf->cert_file = NULL; diff --git a/src/guacd/conf-file.h b/src/guacd/conf-file.h index ae8744c7..d9344942 100644 --- a/src/guacd/conf-file.h +++ b/src/guacd/conf-file.h @@ -25,6 +25,8 @@ #include "config.h" +#include + /** * The contents of a guacd configuration file. */ @@ -62,6 +64,11 @@ typedef struct guacd_config { char* key_file; #endif + /** + * The maximum log level to be logged by guacd. + */ + guac_client_log_level max_log_level; + } guacd_config; /** diff --git a/src/guacd/man/guacd.conf.5 b/src/guacd/man/guacd.conf.5 index 9b7b41ef..b1edf373 100644 --- a/src/guacd/man/guacd.conf.5 +++ b/src/guacd/man/guacd.conf.5 @@ -86,6 +86,19 @@ will bind to port 4822. . .SH DAEMON PARAMETERS .TP +\fBlog_level\fR \fB=\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 \fBpid_file\fR \fB=\fR \fIFILE\fR Causes .B guacd