1 #include "../../git-compat-util.h"
3 static HANDLE ms_eventlog;
5 void openlog(const char *ident, int logopt, int facility)
10 ms_eventlog = RegisterEventSourceA(NULL, ident);
13 warning("RegisterEventSource() failed: %lu", GetLastError());
16 void syslog(int priority, const char *fmt, ...)
27 str_len = vsnprintf(NULL, 0, fmt, ap);
31 warning_errno("vsnprintf failed");
35 str = malloc(st_add(str_len, 1));
37 warning_errno("malloc failed");
42 vsnprintf(str, str_len + 1, fmt, ap);
45 while ((pos = strstr(str, "%1")) != NULL) {
46 str = realloc(str, st_add(++str_len, 1));
48 warning_errno("realloc failed");
51 memmove(pos + 2, pos + 1, strlen(pos));
60 logtype = EVENTLOG_ERROR_TYPE;
64 logtype = EVENTLOG_WARNING_TYPE;
71 logtype = EVENTLOG_INFORMATION_TYPE;
75 ReportEventA(ms_eventlog, logtype, 0, 0, NULL, 1, 0,
76 (const char **)&str, NULL);