You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by ca...@apache.org on 2006/12/15 23:47:56 UTC

svn commit: r487701 - in /logging/log4j/trunk: build.xml src/java/org/apache/log4j/nt/MSG00001.bin src/java/org/apache/log4j/nt/NTEventLogAppender.rc src/java/org/apache/log4j/nt/nteventlog.cpp

Author: carnold
Date: Fri Dec 15 14:47:55 2006
New Revision: 487701

URL: http://svn.apache.org/viewvc?view=rev&rev=487701
Log:
Bug 41169: NTEventLogAppender.dll missing event description

Added:
    logging/log4j/trunk/src/java/org/apache/log4j/nt/NTEventLogAppender.rc
Modified:
    logging/log4j/trunk/build.xml
    logging/log4j/trunk/src/java/org/apache/log4j/nt/MSG00001.bin
    logging/log4j/trunk/src/java/org/apache/log4j/nt/nteventlog.cpp

Modified: logging/log4j/trunk/build.xml
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/build.xml?view=diff&rev=487701&r1=487700&r2=487701
==============================================================================
--- logging/log4j/trunk/build.xml (original)
+++ logging/log4j/trunk/build.xml Fri Dec 15 14:47:55 2006
@@ -625,14 +625,7 @@
     
     <target name="build.nt.dll" depends="log4j.jar,log4j-nt.jar" description="Build NTEventLogAppender.dll">
         <!--  requires MinGW on path.  If cygwin is on path, MinGW must be before it -->
-        <exec executable="windres" dir="${java.source.dir}/org/apache/log4j/nt/">
-            <arg value="-o"/>
-            <arg file="${javac.dest}/EventLogCategories.o"/>
-            <arg value="--include-dir=${javac.dest}"/>
-            <arg file="${java.source.dir}/org/apache/log4j/nt/EventLogCategories.rc"/>
-        </exec>
-
-        <exec executable="windres">
+        <exec executable="windres"  dir="${java.source.dir}/org/apache/log4j/nt/">
             <arg value="-o"/>
             <arg file="${javac.dest}/NTEventLogAppender.o"/>
             <arg file="${java.source.dir}org/apache/log4j/nt/NTEventLogAppender.rc"/>
@@ -652,9 +645,8 @@
 			<arg value="-I${jni.include.dir}\win32"/>
 			<arg value="-I${javac.dest}"/>
 			<arg value="-shared"/>
-			<arg file="${java.source.dir}org/apache/log4j/nt/nteventlog.cpp"/>
+			<arg file="${java.source.dir}/org/apache/log4j/nt/nteventlog.cpp"/>
 			<arg file="${javac.dest}/NTEventLogAppender.o"/>
-			<arg file="${javac.dest}/EventLogCategories.o"/>
 			<arg value="-o"/>
 			<arg file="${jar.dest}/NTEventLogAppender.dll"/>
 		</exec>

Modified: logging/log4j/trunk/src/java/org/apache/log4j/nt/MSG00001.bin
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/java/org/apache/log4j/nt/MSG00001.bin?view=diff&rev=487701&r1=487700&r2=487701
==============================================================================
Binary files - no diff available.

Added: logging/log4j/trunk/src/java/org/apache/log4j/nt/NTEventLogAppender.rc
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/java/org/apache/log4j/nt/NTEventLogAppender.rc?view=auto&rev=487701
==============================================================================
--- logging/log4j/trunk/src/java/org/apache/log4j/nt/NTEventLogAppender.rc (added)
+++ logging/log4j/trunk/src/java/org/apache/log4j/nt/NTEventLogAppender.rc Fri Dec 15 14:47:55 2006
@@ -0,0 +1,125 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License. 
+//
+//
+//   Message file include
+//
+LANGUAGE 0x9,0x1
+1 11 MSG00001.bin
+// Microsoft Visual C++ generated resource script.
+//
+#include "windows.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+//#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE 
+BEGIN
+    "resource.h\0"
+END
+
+2 TEXTINCLUDE 
+BEGIN
+    "#include ""afxres.h""\r\n"
+    "\0"
+END
+
+3 TEXTINCLUDE 
+BEGIN
+    "\r\n"
+    "\0"
+END
+
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION  1, 2, 15, 1
+ PRODUCTVERSION 1, 2, 15, 1
+ FILEFLAGSMASK 0x17L
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "040904b0"
+        BEGIN
+            VALUE "CompanyName", "Apache Software Foundation"
+            VALUE "FileDescription", "Platform methods for NTEventLogAppender"
+            VALUE "FileVersion", "1, 2, 15, 1"
+            VALUE "InternalName", "NTEventLogAppender"
+            VALUE "LegalCopyright", "Copyright (C) 2005, Apache Software Foundation"
+            VALUE "OriginalFilename", "NTEventLogAppender.dll"
+            VALUE "ProductName", "log4j"
+            VALUE "ProductVersion", "1, 2, 15, 1" 
+        END
+    END
+    BLOCK "VarFileInfo"
+    BEGIN
+        VALUE "Translation", 0x409, 1200
+    END
+END
+
+#endif    // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif    // not APSTUDIO_INVOKED
+

Modified: logging/log4j/trunk/src/java/org/apache/log4j/nt/nteventlog.cpp
URL: http://svn.apache.org/viewvc/logging/log4j/trunk/src/java/org/apache/log4j/nt/nteventlog.cpp?view=diff&rev=487701&r1=487700&r2=487701
==============================================================================
--- logging/log4j/trunk/src/java/org/apache/log4j/nt/nteventlog.cpp (original)
+++ logging/log4j/trunk/src/java/org/apache/log4j/nt/nteventlog.cpp Fri Dec 15 14:47:55 2006
@@ -33,8 +33,23 @@
  * be displayed in the NT Event Viewer.
  */
 WORD getCategory(jint priority) {
-  // Priority values map directly to EventLog category values
-  return (WORD)(priority + 1);
+  WORD category = 1;
+  if (priority >= org_apache_log4j_Priority_DEBUG_INT) {
+      category = 2;
+      if (priority >= org_apache_log4j_Priority_INFO_INT) {
+          category = 3;
+          if (priority >= org_apache_log4j_Priority_WARN_INT) {
+             category = 4;
+             if (priority >= org_apache_log4j_Priority_ERROR_INT) {
+                category = 5;
+                if (priority >= org_apache_log4j_Priority_FATAL_INT) {
+                    category = 6;
+                }
+             }
+          }
+      }
+  }
+  return category;
 }
 
 /*
@@ -43,23 +58,17 @@
  * 3 event types of interest to us: ERROR, WARNING, and INFO.
  */
 WORD getType(jint priority) {
-  WORD ret_val;
-  
-  switch (priority) {
-  case org_apache_log4j_Priority_FATAL_INT:
-  case org_apache_log4j_Priority_ERROR_INT:
-    ret_val = EVENTLOG_ERROR_TYPE;
-    break;
-  case org_apache_log4j_Priority_WARN_INT:
-    ret_val = EVENTLOG_WARNING_TYPE;
-    break;
-  case org_apache_log4j_Priority_INFO_INT:
-  case org_apache_log4j_Priority_DEBUG_INT:
-  default:
-    ret_val = EVENTLOG_INFORMATION_TYPE;
-    break;
+  WORD type = EVENTLOG_SUCCESS;
+  if (priority >= org_apache_log4j_Priority_INFO_INT) {
+      type = EVENTLOG_INFORMATION_TYPE;
+      if (priority >= org_apache_log4j_Priority_WARN_INT) {
+          type = EVENTLOG_WARNING_TYPE;
+          if (priority >= org_apache_log4j_Priority_ERROR_INT) {
+             type = EVENTLOG_ERROR_TYPE;
+          }
+      }
   }
-  return ret_val;
+  return type;
 }
 
 HKEY regGetKey(wchar_t *subkey, DWORD *disposition) {
@@ -71,7 +80,8 @@
 }
 
 void regSetString(HKEY hkey, wchar_t *name, wchar_t *value) {
-  RegSetValueExW(hkey, name, 0, REG_SZ, (LPBYTE)value, (wcslen(value) + 1) * sizeof(wchar_t));
+  RegSetValueExW(hkey, name, 0, REG_EXPAND_SZ, 
+      (LPBYTE)value, (wcslen(value) + 1) * sizeof(wchar_t));
 }
 
 void regSetDword(HKEY hkey, wchar_t *name, DWORD value) {
@@ -91,15 +101,19 @@
   wcscat(subkey, source);
   hkey = regGetKey(subkey, &disposition);
   if (disposition == REG_CREATED_NEW_KEY) {
-    regSetString(hkey, L"EventMessageFile", L"NTEventLogAppender.dll");
-    regSetString(hkey, L"CategoryMessageFile", L"NTEventLogAppender.dll");
+    HMODULE hmodule = GetModuleHandleW(L"NTEventLogAppender.dll");
+    if (hmodule != NULL) {
+        wchar_t modpath[_MAX_PATH];
+        DWORD modlen = GetModuleFileNameW(hmodule, modpath, _MAX_PATH - 1);
+        if (modlen > 0) {
+            modpath[modlen] = 0;
+            regSetString(hkey, L"EventMessageFile", modpath);
+            regSetString(hkey, L"CategoryMessageFile", modpath);
+        }
+    }
     regSetDword(hkey, L"TypesSupported", (DWORD)7);
-    regSetDword(hkey, L"CategoryCount", (DWORD)8);
+    regSetDword(hkey, L"CategoryCount", (DWORD) 6);
   }
-	//RegSetValueEx(hkey, "EventMessageFile", 0, REG_SZ, (LPBYTE)dllname, lstrlen(dllname));
-	//RegSetValueEx(hkey, "CategoryMessageFile", 0, REG_SZ, (LPBYTE)dllname, lstrlen(dllname));
-	//RegSetValueEx(hkey, "TypesSupported", 0, REG_DWORD, (LPBYTE)&whichTypes, sizeof(DWORD));
-	//RegSetValueEx(hkey, "CategoryCount", 0, REG_DWORD, (LPBYTE)&numCategories, sizeof(DWORD));
   RegCloseKey(hkey);
   return;
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org