1 #include "../../git-compat-util.h"
2 #include "../../strbuf.h"
4 static HANDLE ms_eventlog
;
6 void openlog(const char *ident
, int logopt
, int facility
)
11 ms_eventlog
= RegisterEventSourceA(NULL
, ident
);
14 warning("RegisterEventSource() failed: %lu", GetLastError());
17 void syslog(int priority
, const char *fmt
, ...)
19 struct strbuf sb
= STRBUF_INIT
;
20 struct strbuf_expand_dict_entry dict
[] = {
33 str_len
= vsnprintf(NULL
, 0, fmt
, ap
);
37 warning("vsnprintf failed: '%s'", strerror(errno
));
41 str
= malloc(str_len
+ 1);
43 vsnprintf(str
, str_len
+ 1, fmt
, ap
);
45 strbuf_expand(&sb
, str
, strbuf_expand_dict_cb
, &dict
);
53 logtype
= EVENTLOG_ERROR_TYPE
;
57 logtype
= EVENTLOG_WARNING_TYPE
;
64 logtype
= EVENTLOG_INFORMATION_TYPE
;
68 ReportEventA(ms_eventlog
, logtype
, 0, 0, NULL
, 1, 0,
69 (const char **)&sb
.buf
, NULL
);