From e910dcbfcc436b527c0217e5ce5b5e1b9b0d48d7 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Wed, 29 Mar 2017 22:32:01 -0700 Subject: [PATCH] GUACAMOLE-259: Add TRACE log level. --- src/guacd/conf-args.c | 2 +- src/guacd/conf-file.c | 2 +- src/guacd/conf-parse.c | 1 + src/guacd/log.c | 6 ++++++ src/guacd/man/guacd.8 | 1 + src/guacd/man/guacd.conf.5 | 1 + src/libguac/guacamole/client-types.h | 17 +++++++++++++---- 7 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/guacd/conf-args.c b/src/guacd/conf-args.c index 54551dfd..448f84d6 100644 --- a/src/guacd/conf-args.c +++ b/src/guacd/conf-args.c @@ -63,7 +63,7 @@ int guacd_conf_parse_args(guacd_config* config, int argc, char** argv) { /* 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"); + fprintf(stderr, "Invalid log level. Valid levels are: \"trace\", \"debug\", \"info\", \"warning\", and \"error\".\n"); return 1; } diff --git a/src/guacd/conf-file.c b/src/guacd/conf-file.c index 760f24fe..ba32c788 100644 --- a/src/guacd/conf-file.c +++ b/src/guacd/conf-file.c @@ -78,7 +78,7 @@ static int guacd_conf_callback(const char* section, const char* param, const cha /* Invalid log level */ if (level < 0) { - guacd_conf_parse_error = "Invalid log level. Valid levels are: \"debug\", \"info\", \"warning\", and \"error\"."; + guacd_conf_parse_error = "Invalid log level. Valid levels are: \"trace\", \"debug\", \"info\", \"warning\", and \"error\"."; return 1; } diff --git a/src/guacd/conf-parse.c b/src/guacd/conf-parse.c index b4181010..e5a034f2 100644 --- a/src/guacd/conf-parse.c +++ b/src/guacd/conf-parse.c @@ -527,6 +527,7 @@ int guacd_parse_log_level(const char* name) { if (strcmp(name, "error") == 0) return GUAC_LOG_ERROR; if (strcmp(name, "warning") == 0) return GUAC_LOG_WARNING; if (strcmp(name, "debug") == 0) return GUAC_LOG_DEBUG; + if (strcmp(name, "trace") == 0) return GUAC_LOG_TRACE; /* No such log level */ return -1; diff --git a/src/guacd/log.c b/src/guacd/log.c index 121bb699..c99a5ed8 100644 --- a/src/guacd/log.c +++ b/src/guacd/log.c @@ -72,6 +72,12 @@ void vguacd_log(guac_client_log_level level, const char* format, priority_name = "DEBUG"; break; + /* Trace log level */ + case GUAC_LOG_TRACE: + priority = LOG_DEBUG; + priority_name = "TRACE"; + break; + /* Any unknown/undefined log level */ default: priority = LOG_INFO; diff --git a/src/guacd/man/guacd.8 b/src/guacd/man/guacd.8 index afdf667c..c68af365 100644 --- a/src/guacd/man/guacd.8 +++ b/src/guacd/man/guacd.8 @@ -66,6 +66,7 @@ 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 trace, .B debug, .B info, .B warning, diff --git a/src/guacd/man/guacd.conf.5 b/src/guacd/man/guacd.conf.5 index eacd52c4..4605f7d7 100644 --- a/src/guacd/man/guacd.conf.5 +++ b/src/guacd/man/guacd.conf.5 @@ -109,6 +109,7 @@ 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 trace, .B debug, .B info, .B warning, diff --git a/src/libguac/guacamole/client-types.h b/src/libguac/guacamole/client-types.h index 636ac9bc..1caa6bcb 100644 --- a/src/libguac/guacamole/client-types.h +++ b/src/libguac/guacamole/client-types.h @@ -56,8 +56,8 @@ typedef enum guac_client_state { /** * All supported log levels used by the logging subsystem of each Guacamole - * client. These log levels correspond to a subset of the log levels defined by - * RFC 5424. + * client. With the exception of GUAC_LOG_TRACE, these log levels correspond to + * a subset of the log levels defined by RFC 5424. */ typedef enum guac_client_log_level { @@ -78,9 +78,18 @@ typedef enum guac_client_log_level { /** * Informational messages which can be useful for debugging, but are - * otherwise not useful to users or administrators. + * otherwise not useful to users or administrators. It is expected that + * debug level messages, while verbose, will not negatively affect + * performance. */ - GUAC_LOG_DEBUG = 7 + GUAC_LOG_DEBUG = 7, + + /** + * Informational messages which can be useful for debugging, like + * GUAC_LOG_DEBUG, but which are so low-level that they may affect + * performance. + */ + GUAC_LOG_TRACE = 8 } guac_client_log_level;