11 static HANDLE hEventLog = NULL;
14 * Close the Handle to the application Event Log
18 DeregisterEventSource(hEventLog);
22 * Initialize event logging
25 openlog(const char *ident, int logopt, int facility) {
26 /* Get a handle to the Application event log */
27 hEventLog = RegisterEventSourceA(NULL, ident);
31 * Log to the NT Event Log
34 syslog(int priority, const char *message, ...) {
41 va_start(ap, message);
42 vsprintf(buf, message, ap);
45 /* Make sure that the channel is open to write the event */
46 if (hEventLog == NULL) {
47 openlog("SoftHSM", 0, 0);
49 if (hEventLog != NULL) {
54 ReportEventA(hEventLog, EVENTLOG_INFORMATION_TYPE, 0,
55 0x40000003, NULL, 1, 0, str, NULL);
58 ReportEventA(hEventLog, EVENTLOG_WARNING_TYPE, 0,
59 0x80000002, NULL, 1, 0, str, NULL);
62 ReportEventA(hEventLog, EVENTLOG_ERROR_TYPE, 0,
63 0xc0000001, NULL, 1, 0, str, NULL);