Mercurial > trustbridge
diff common/logging.c @ 620:bc02ee484067
Add dummy logging with ressourced messages.
The hack in icon.rc is necessary as with mingw 3.0 there appears
to be a problem to include multiple resources after another.
The data is included but the sections are not detected correctly
in windows. Combining them in a single resource fixes this.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Thu, 19 Jun 2014 17:48:10 +0200 |
parents | 0172740f5c6e |
children | 5042ace08cba |
line wrap: on
line diff
--- a/common/logging.c Thu Jun 19 17:45:06 2014 +0200 +++ b/common/logging.c Thu Jun 19 17:48:10 2014 +0200 @@ -16,6 +16,7 @@ #ifdef WIN32 # include <windows.h> +# include "events.h" #else # include <syslog.h> #endif @@ -28,9 +29,7 @@ HANDLE log_src = NULL, process_token = NULL; wchar_t *wmsg = NULL; - BOOL failure = TRUE; - WORD type = 0, - category = 0; + BOOL success = FALSE; char buffer[MAX_LOG+1]; PTOKEN_USER user_struct = NULL; PSID user_sid = NULL; @@ -38,7 +37,7 @@ vsnprintf (buffer, MAX_LOG, format, ap); buffer[MAX_LOG] = '\0'; - log_src = RegisterEventSourceA (NULL, LOG_NAME); + log_src = RegisterEventSourceW (NULL, L"" LOG_NAME); if (log_src == NULL) { @@ -46,15 +45,6 @@ return; } - if (error) - { - type = EVENTLOG_ERROR_TYPE; - } - else - { - type = EVENTLOG_INFORMATION_TYPE; - } - wmsg = utf8_to_wchar (buffer, strlen(buffer)); if (wmsg == NULL) { @@ -80,16 +70,16 @@ } - failure = ReportEventW (log_src, - type, - category, - 0, + success = ReportEventW (log_src, + error ? EVENTLOG_ERROR_TYPE : EVENTLOG_INFORMATION_TYPE, + EVENT_CAT_TB, + error ? MSG_DEFAULT_ERROR : MSG_DEFAULT_INFO, user_sid, 1, 0, (const WCHAR **) &wmsg, NULL); - if (failure) + if (!success) { PRINTLASTERROR ("Failed to report event."); }