GUAC-911: Use guacd namespace. Replace log_prefix with macro. Use same log name for all.

This commit is contained in:
Michael Jumper 2014-11-09 17:09:35 -08:00
parent c3f98b388a
commit 4b92233084
3 changed files with 8 additions and 14 deletions

View File

@ -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);

View File

@ -31,10 +31,7 @@
#include <syslog.h>
#include <unistd.h>
/* 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);
}

View File

@ -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,