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("vsnprintf failed: '%s'", strerror(errno));
35 str = malloc(str_len + 1);
37 warning("malloc failed: '%s'", strerror(errno));
42 vsnprintf(str, str_len + 1, fmt, ap);
45 while ((pos = strstr(str, "%1")) != NULL) {
46 str = realloc(str, ++str_len + 1);
48 warning("realloc failed: '%s'", strerror(errno));
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);