summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Baumann <abaumann@yahoo.com>2009-03-19 11:23:44 +0100
committerAndreas Baumann <abaumann@yahoo.com>2009-03-19 11:23:44 +0100
commit02c0ec4727710a679bd2f436a6fe67b707a22c84 (patch)
tree19f26cf4d0cd659dc13d68f6352f7b4537fd0eba
parent59218203a248a958ad5cb281507dbd7ad3255334 (diff)
downloadwolfbones-02c0ec4727710a679bd2f436a6fe67b707a22c84.tar.gz
wolfbones-02c0ec4727710a679bd2f436a6fe67b707a22c84.tar.bz2
big logger cleanup on Windows, local testmsg.dll for log test
-rw-r--r--include/wolf/log/log.h15
-rw-r--r--makefiles/nmake/compiler.mk2
-rw-r--r--makefiles/nmake/wolf.mc0
-rw-r--r--src/Makefile.W326
-rw-r--r--src/log/log.c9
-rw-r--r--tests/log/Makefile.W3212
-rw-r--r--tests/log/test_log.c3
7 files changed, 28 insertions, 19 deletions
diff --git a/include/wolf/log/log.h b/include/wolf/log/log.h
index 4603be3..c272d31 100644
--- a/include/wolf/log/log.h
+++ b/include/wolf/log/log.h
@@ -202,16 +202,21 @@ void wolf_log_openlogtosyslog( const char *ident,
/**
* Open a channel to the Windows event logger.
*
- * @param server name of the server to log to, NULL if local computer
- * @param log name of the log, usually this should be 'Application'
- * @param source name of the event log source
- * @param level one out of wolf_log_level_t, the minimal level which
- * should be logged into the event log
+ * @param server name of the server to log to, NULL if local computer
+ * @param log name of the log, usually this should be 'Application'
+ * @param source name of the event log source
+ * @param path_to_dll path to the message/category DLL for the localization
+ * of the categories and messages to log. the string should
+ * be expandable, i.e. about hard-coded drives and paths,
+ * e. g. "%SystemRoot%\\System32\\myapp.dll"
+ * @param level one out of wolf_log_level_t, the minimal level which
+ * should be logged into the event log
*
*/
void wolf_log_openlogtoeventlog( const char *server,
const char *log,
const char *source,
+ const char *path_to_dll,
wolf_log_level_t level );
#endif /* defined HAVE_EVENTLOG */
diff --git a/makefiles/nmake/compiler.mk b/makefiles/nmake/compiler.mk
index 4006124..51c8596 100644
--- a/makefiles/nmake/compiler.mk
+++ b/makefiles/nmake/compiler.mk
@@ -47,7 +47,7 @@ CCPP_LINK = link.exe
$(CCPP_LINK) $(LDFLAGS) $(LIBS) /out:$@ $< $(OBJS)
.mc.rc:
- $(MC) $<
+ $(MC) -h $(@D) -r $(@D) $<
.rc.res:
$(RC) $<
diff --git a/makefiles/nmake/wolf.mc b/makefiles/nmake/wolf.mc
deleted file mode 100644
index e69de29..0000000
--- a/makefiles/nmake/wolf.mc
+++ /dev/null
diff --git a/src/Makefile.W32 b/src/Makefile.W32
index 4ab65e6..1685859 100644
--- a/src/Makefile.W32
+++ b/src/Makefile.W32
@@ -15,7 +15,8 @@ LIBRARIES = \
PORT_OBJS = \
port\string.obj \
port\stdio.obj \
- port\time.obj
+ port\time.obj \
+ port\snprintf.obj
LOG_OBJS = \
log\log.obj
@@ -40,7 +41,8 @@ log\wolfmsg.res: log\wolfmsg.rc
local_all:
local_clean:
- @-erase $(LIBRARIES) log\wolfmsg.h 2>NUL
+ @-erase $(LIBRARIES) 2>NUL
+ @-erase log\MSG*.bin log\wolfmsg.rc log\wolfmsg.h log\wolfmsg.res 2>NUL
local_distclean:
diff --git a/src/log/log.c b/src/log/log.c
index 9aad099..6b7e9a5 100644
--- a/src/log/log.c
+++ b/src/log/log.c
@@ -406,7 +406,7 @@ static void registry_set_word( HKEY h, TCHAR *name, DWORD value ) {
RegSetValueEx( h, name, 0, REG_DWORD, (LPBYTE)&value, sizeof( DWORD ) );
}
-static void register_event_source( const char *log, const char *source ) {
+static void register_event_source( const char *log, const char *source, const char *path_to_dll ) {
char key[256];
HKEY h = 0;
DWORD disposition;
@@ -418,8 +418,8 @@ static void register_event_source( const char *log, const char *source ) {
/* make sure not to have hard-coded pathes here, otherwise remote
* event logging will not work! */
- registry_set_expandable_string( h, "EventMessageFile", "%SystemRoot%\\System32\\wolfmsg.dll" );
- registry_set_expandable_string( h, "CategoryMessageFile", "%SystemRoot%\\System32\\wolfmsg.dll" );
+ registry_set_expandable_string( h, "EventMessageFile", (char *)path_to_dll );
+ registry_set_expandable_string( h, "CategoryMessageFile", (char *)path_to_dll );
registry_set_word( h, "TypesSupported", (DWORD)7 );
registry_set_word( h, "CategoryCount", (DWORD)2 );
RegCloseKey( h );
@@ -491,6 +491,7 @@ static PSID get_current_sid( void ) {
void wolf_log_openlogtoeventlog( const char *server,
const char *log,
const char *source,
+ const char *path_to_dll,
wolf_log_level_t level ) {
eventlog_server = server;
eventlog_log = log;
@@ -501,7 +502,7 @@ void wolf_log_openlogtoeventlog( const char *server,
* message DLL, how many categories we define and what types
* of events we are supporting
*/
- register_event_source( log, source );
+ register_event_source( log, source, path_to_dll );
/* for logging the user of the process into the event log */
sid = get_current_sid( );
diff --git a/tests/log/Makefile.W32 b/tests/log/Makefile.W32
index 0a1b688..de5f8f4 100644
--- a/tests/log/Makefile.W32
+++ b/tests/log/Makefile.W32
@@ -3,7 +3,7 @@ TOPDIR = ..\..
SUBDIRS =
INCLUDE_DIRS = \
- /I$(TOPDIR)\include\wolf /I.
+ /I$(TOPDIR)\include\wolf /I. \
/D_WIN32_WINNT=0x400 /I"$(PLATFORM_SDK_DIR)\Include"
INCLUDE_LDFLAGS = \
@@ -14,7 +14,7 @@ INCLUDE_LIBS = \
advapi32.lib
LIBRARIES = \
- log\testmsg.dll
+ testmsg.dll
TEST_BINS = \
test_log.exe
@@ -23,11 +23,11 @@ TEST_BINS = \
test_log.exe: test_log.obj $(TOPDIR)\src\wolf.lib
-log\testmsg.dll: log\testmsg.res
+testmsg.dll: testmsg.res
$(LINK) /dll /nologo /noentry /MACHINE:x86 /out:$@ $?
-log\testmsg.rc: log\testmsg.mc
-log\testmsg.res: log\testmsg.rc
+testmsg.rc: testmsg.mc
+testmsg.res: testmsg.rc
local_test: $(LIBRARIES)
@echo Testing log..
@@ -37,7 +37,7 @@ local_all:
local_clean:
@-erase test.log 2>NUL
- @-erase $(LIBRARIES) log\testmsg.h 2>NUL
+ @-erase $(LIBRARIES) testmsg.h 2>NUL
local_distclean:
diff --git a/tests/log/test_log.c b/tests/log/test_log.c
index 39c861e..388cafb 100644
--- a/tests/log/test_log.c
+++ b/tests/log/test_log.c
@@ -19,7 +19,8 @@ int main( void ) {
WOLF_LOG_SYSLOG_DEFAULT_OPTIONS );
#endif
#if defined WOLF_LOG_HAVE_EVENTLOG
- wolf_log_openlogtoeventlog( NULL, "Application", "wolf_log_test", WOLF_LOG_NOTICE );
+ wolf_log_openlogtoeventlog( NULL, "Application", "wolf_log_test",
+ "C:\\Temp\\testmsg.dll", WOLF_LOG_NOTICE );
#endif
wolf_log( WOLF_LOG_NOTICE, WOLF_CATEGORY_TEST_LOG, WOLF_MSG_TEST_LOG_MSG1, "Started the logger" );