GUAC-911: Add config file option for log levels.

This commit is contained in:
Michael Jumper 2014-11-09 16:56:04 -08:00
parent f71067b024
commit 049c366b78
3 changed files with 47 additions and 0 deletions

View File

@ -25,6 +25,8 @@
#include "conf-file.h" #include "conf-file.h"
#include "conf-parse.h" #include "conf-parse.h"
#include <guacamole/client.h>
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -72,6 +74,30 @@ static int guacd_conf_callback(const char* section, const char* param, const cha
return 0; 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 */ /* SSL-specific options */
@ -163,6 +189,7 @@ guacd_config* guacd_conf_load() {
conf->bind_port = strdup("4822"); conf->bind_port = strdup("4822");
conf->pidfile = NULL; conf->pidfile = NULL;
conf->foreground = 0; conf->foreground = 0;
conf->max_log_level = GUAC_LOG_INFO;
#ifdef ENABLE_SSL #ifdef ENABLE_SSL
conf->cert_file = NULL; conf->cert_file = NULL;

View File

@ -25,6 +25,8 @@
#include "config.h" #include "config.h"
#include <guacamole/client.h>
/** /**
* The contents of a guacd configuration file. * The contents of a guacd configuration file.
*/ */
@ -62,6 +64,11 @@ typedef struct guacd_config {
char* key_file; char* key_file;
#endif #endif
/**
* The maximum log level to be logged by guacd.
*/
guac_client_log_level max_log_level;
} guacd_config; } guacd_config;
/** /**

View File

@ -86,6 +86,19 @@ will bind to port 4822.
. .
.SH DAEMON PARAMETERS .SH DAEMON PARAMETERS
.TP .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 \fBpid_file\fR \fB=\fR \fIFILE\fR
Causes Causes
.B guacd .B guacd