[Opendnssec-commits] [keihatsu.kirei.se/svn/dnssec] r5311 - in trunk/softHSM: . src/lib

Rickard Bellgrim rickard at opendnssec.org
Mon Jul 11 09:05:30 CEST 2011


Author: rb
Date: 2011-07-11 09:05:29 +0200 (Mon, 11 Jul 2011)
New Revision: 5311

Modified:
   trunk/softHSM/NEWS
   trunk/softHSM/src/lib/log.cpp
Log:
Log to EventLog in Windows


Modified: trunk/softHSM/NEWS
===================================================================
--- trunk/softHSM/NEWS	2011-07-08 14:38:31 UTC (rev 5310)
+++ trunk/softHSM/NEWS	2011-07-11 07:05:29 UTC (rev 5311)
@@ -14,7 +14,7 @@
 * Better signing performance with a single element cache for 
   the PK_Signer object.
 * Document README.MinGW describes how to build on Windows.
-  (Contributed by Jaroslav Imrich)
+  (Text and patches contributed by Jaroslav Imrich)
 
 Bugfixes:
 * API changes in Botan created a namespace collision.
@@ -26,11 +26,12 @@
   if an incorrect PIN has been entered at least once.
 * Windows: Detect LoadLibrary.
 * Windows: Set CRYPTOKI_EXPORTS.
-* Windows: Load library correctly softhsm.
+* Windows: Load library correctly in softhsm.
 * Windows: Compatibility function for getpass.
 * Windows: Use _putenv and not setenv.
 * Windows: Generate the DLL file.
 * Windows: The softhsm tool will use the DLL file by default.
+* Windows: Log to EventLog.
 
 
 SoftHSM 1.2.1 - 2011-05-03 

Modified: trunk/softHSM/src/lib/log.cpp
===================================================================
--- trunk/softHSM/src/lib/log.cpp	2011-07-08 14:38:31 UTC (rev 5310)
+++ trunk/softHSM/src/lib/log.cpp	2011-07-11 07:05:29 UTC (rev 5311)
@@ -35,30 +35,58 @@
 #include "log.h"
 #include "config.h"
 
-#ifdef HAVE_SYSLOG_H
+#ifndef WIN32
 #include <syslog.h>
+#else
+#include <windows.h>
 #endif
 
 void logError(const char *functionName, const char *text) {
-#ifdef HAVE_SYSLOG_H
+#ifndef WIN32
   syslog(LOG_ERR, "SoftHSM: %s: %s", functionName, text);
+#else
+  HANDLE hEventLog = OpenEventLog(NULL, "Application");
+  if(hEventLog) {
+    char msg[1024];
+    snprintf(msg, sizeof(msg), "SoftHSM: %s: %s", functionName, text);
+    ReportEvent(hEventLog, EVENTLOG_ERROR_TYPE, 0, 0, NULL, 1, 0, (LPCWSTR*)msg, NULL));
+    CloseEventLog(hEventLog);
+  }
 #endif
 }
 
 void logWarning(const char *functionName, const char *text) {
-#ifdef HAVE_SYSLOG_H
+#ifndef WIN32
   syslog(LOG_WARNING, "SoftHSM: %s: %s", functionName, text);
+#else
+  HANDLE hEventLog = OpenEventLog(NULL, "Application");
+  if(hEventLog) {
+    char msg[1024];
+    snprintf(msg, sizeof(msg), "SoftHSM: %s: %s", functionName, text);
+    ReportEvent(hEventLog, EVENTLOG_WARNING_TYPE, 0, 0, NULL, 1, 0, (LPCWSTR*)msg, NULL));
+    CloseEventLog(hEventLog);
+  }
 #endif
 }
 
 void logInfo(const char *functionName, const char *text) {
-#ifdef HAVE_SYSLOG_H
+#ifndef WIN32
   syslog(LOG_INFO, "SoftHSM: %s: %s", functionName, text);
+#else
+  HANDLE hEventLog = OpenEventLog(NULL, "Application");
+  if(hEventLog) {
+    char msg[1024];
+    snprintf(msg, sizeof(msg), "SoftHSM: %s: %s", functionName, text);
+    ReportEvent(hEventLog, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0, (LPCWSTR*)msg, NULL));
+    CloseEventLog(hEventLog);
+  }
 #endif
 }
 
 void logDebug(const char *functionName, const char *text) {
-#ifdef HAVE_SYSLOG_H
+#ifndef WIN32
   syslog(LOG_DEBUG, "SoftHSM: %s: %s", functionName, text);
+#else
+  logInfo(functionName, text);
 #endif
 }




More information about the Opendnssec-commits mailing list