GUAC-911: Add and document log level option for guacd.

This commit is contained in:
Michael Jumper 2014-11-09 19:47:11 -08:00
parent 3ff5d5d690
commit f865656991
2 changed files with 31 additions and 1 deletions

View File

@ -24,6 +24,7 @@
#include "conf-args.h" #include "conf-args.h"
#include "conf-file.h" #include "conf-file.h"
#include "conf-parse.h"
#include <getopt.h> #include <getopt.h>
#include <stdio.h> #include <stdio.h>
@ -34,7 +35,7 @@ int guacd_conf_parse_args(guacd_config* config, int argc, char** argv) {
/* Parse arguments */ /* Parse arguments */
int opt; 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 */ /* -l: Bind port */
if (opt == 'l') { if (opt == 'l') {
@ -59,6 +60,20 @@ int guacd_conf_parse_args(guacd_config* config, int argc, char** argv) {
config->pidfile = strdup(optarg); 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 #ifdef ENABLE_SSL
/* -C SSL certificate */ /* -C SSL certificate */
else if (opt == 'C') { else if (opt == 'C') {
@ -88,6 +103,7 @@ int guacd_conf_parse_args(guacd_config* config, int argc, char** argv) {
" [-l LISTENPORT]" " [-l LISTENPORT]"
" [-b LISTENADDRESS]" " [-b LISTENADDRESS]"
" [-p PIDFILE]" " [-p PIDFILE]"
" [-L LEVEL]"
#ifdef ENABLE_SSL #ifdef ENABLE_SSL
" [-C CERTIFICATE_FILE]" " [-C CERTIFICATE_FILE]"
" [-K PEM_FILE]" " [-K PEM_FILE]"

View File

@ -8,6 +8,7 @@ guacd \- Guacamole proxy daemon
[\fB-b\fR \fIHOST\fR] [\fB-b\fR \fIHOST\fR]
[\fB-l\fR \fIPORT\fR] [\fB-l\fR \fIPORT\fR]
[\fB-p\fR \fIPID FILE\fR] [\fB-p\fR \fIPID FILE\fR]
[\fB-L\fR \fILOG LEVEL\fR]
[\fB-C\fR \fICERTIFICATE FILE\fR] [\fB-C\fR \fICERTIFICATE FILE\fR]
[\fB-K\fR \fIKEY FILE\fR] [\fB-K\fR \fIKEY FILE\fR]
[\fB-f\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 file. This is useful for init scripts and is used by the provided init
script. script.
.TP .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 \fB\-f\fR
Causes Causes
.B guacd .B guacd