Skip to content

Commit

Permalink
Fix logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmuehlner committed Jan 26, 2024
1 parent 4229900 commit 5b5d949
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/protocols/vnc/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,15 @@
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>

/*
* Syslog does not exist on Windows, so we'll just log directly to std error.
* TODO: ReportEvent() might be sort of equivalent? Look into
* https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-reporteventa
*/
#ifndef WINDOWS_BUILD
#include <syslog.h>
#endif

void guac_vnc_client_log_info(const char* format, ...) {

Expand All @@ -46,8 +54,12 @@ void guac_vnc_client_log_info(const char* format, ...) {
vsnprintf(message, sizeof(message), format, args);
va_end(args);

#ifndef WINDOWS_BUILD
/* Log to syslog */
syslog(LOG_INFO, "%s", message);
#else
fprintf(stderr, "INFO: %s\n", message);
#endif

}

Expand All @@ -61,8 +73,12 @@ void guac_vnc_client_log_error(const char* format, ...) {
vsnprintf(message, sizeof(message), format, args);
va_end(args);

#ifndef WINDOWS_BUILD
/* Log to syslog */
syslog(LOG_ERR, "%s", message);
#else
fprintf(stderr, "ERROR: %s\n", message);
#endif

}

0 comments on commit 5b5d949

Please sign in to comment.