From 4b922330848c4a1592619d3dfc119db595799ad4 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 9 Nov 2014 17:09:35 -0800 Subject: [PATCH] GUAC-911: Use guacd namespace. Replace log_prefix with macro. Use same log name for all. --- src/guacd/daemon.c | 7 ++----- src/guacd/log.c | 11 ++++------- src/guacd/log.h | 4 ++-- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/guacd/daemon.c b/src/guacd/daemon.c index 45ca1f82..f7cfdaee 100644 --- a/src/guacd/daemon.c +++ b/src/guacd/daemon.c @@ -389,12 +389,9 @@ int main(int argc, char* argv[]) { if (config == NULL || guacd_conf_parse_args(config, argc, argv)) exit(EXIT_FAILURE); - /* Set up logging prefix */ - strncpy(log_prefix, basename(argv[0]), sizeof(log_prefix)); - /* Init logging as early as possible */ - log_level = config->max_log_level; - openlog("guacd", LOG_PID, LOG_DAEMON); + guacd_log_level = config->max_log_level; + openlog(GUACD_LOG_NAME, LOG_PID, LOG_DAEMON); /* Log start */ guacd_log(GUAC_LOG_INFO, "Guacamole proxy daemon (guacd) version " VERSION); diff --git a/src/guacd/log.c b/src/guacd/log.c index c6252ac3..2b4f4a41 100644 --- a/src/guacd/log.c +++ b/src/guacd/log.c @@ -31,10 +31,7 @@ #include #include -/* Log prefix, defaulting to "guacd" */ -char log_prefix[64] = "guacd"; - -int log_level = GUAC_LOG_INFO; +int guacd_log_level = GUAC_LOG_INFO; void vguacd_log(guac_client_log_level level, const char* format, va_list args) { @@ -45,7 +42,7 @@ void vguacd_log(guac_client_log_level level, const char* format, char message[2048]; /* Don't bother if the log level is too high */ - if (level > log_level) + if (level > guacd_log_level) return; /* Copy log message into buffer */ @@ -90,8 +87,8 @@ void vguacd_log(guac_client_log_level level, const char* format, /* Log to STDERR, if high enough log level */ if (priority <= LOG_INFO) - fprintf(stderr, "%s[%i]: %s: %s\n", log_prefix, getpid(), - priority_name, message); + fprintf(stderr, GUACD_LOG_NAME "[%i]: %s: %s\n", + getpid(), priority_name, message); } diff --git a/src/guacd/log.h b/src/guacd/log.h index 644f6a32..584ffdff 100644 --- a/src/guacd/log.h +++ b/src/guacd/log.h @@ -32,12 +32,12 @@ * The maximum level at which to log messages. All other messages will be * dropped. */ -extern int log_level; +extern int guacd_log_level; /** * The string to prepend to all log messages. */ -extern char log_prefix[64]; +#define GUACD_LOG_NAME "guacd" /** * Writes a message to guacd's logs. This function takes a format and va_list,