diff options
author | Andreas Baumann <abaumann@yahoo.com> | 2012-09-05 21:39:19 +0200 |
---|---|---|
committer | Andreas Baumann <abaumann@yahoo.com> | 2012-09-05 21:39:19 +0200 |
commit | a29c464aa72d46cc956ac2752a2518526c499716 (patch) | |
tree | 96eebb1fb5b0070d196e04db0b73486b39decc14 | |
parent | df2c44401f8dd736a903e73813e5f83fb15b36b6 (diff) | |
download | crawler-a29c464aa72d46cc956ac2752a2518526c499716.tar.gz crawler-a29c464aa72d46cc956ac2752a2518526c499716.tar.bz2 |
started to solve the logger dll problem on Windows
-rwxr-xr-x | include/logger/ConsoleLogSink.hpp | 2 | ||||
-rwxr-xr-x | include/logger/FileLogSink.hpp | 2 | ||||
-rwxr-xr-x | include/logger/LogSink.hpp | 3 | ||||
-rwxr-xr-x | include/logger/Logger.hpp | 29 | ||||
-rwxr-xr-x | include/logger/SyslogLogSink.hpp | 2 | ||||
-rwxr-xr-x | include/logger/WinDbgLogSink.hpp | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | include/util/Exportable.hpp | 4 | ||||
-rwxr-xr-x[-rw-r--r--] | include/util/ScopedPtr.hpp | 0 | ||||
-rwxr-xr-x | src/Makefile.W32 | 12 | ||||
-rwxr-xr-x | src/logger/Makefile.W32 | 47 | ||||
-rw-r--r-- | src/modules/urlfilter/protocol/GNUmakefile | 4 | ||||
-rwxr-xr-x | src/modules/urlfilter/protocol/Makefile.W32 | 8 | ||||
-rwxr-xr-x | src/modules/urlnormalizer/googleurl/Makefile.W32 | 2 | ||||
-rwxr-xr-x | src/modules/urlnormalizer/simpleurl/Makefile.W32 | 4 | ||||
-rwxr-xr-x | tests/logger/Makefile.W32 | 5 | ||||
-rwxr-xr-x | tests/logger/exec_test.cmd | 3 | ||||
-rw-r--r-- | tests/logger/test1.MUST.WIN32 | 18 |
17 files changed, 87 insertions, 60 deletions
diff --git a/include/logger/ConsoleLogSink.hpp b/include/logger/ConsoleLogSink.hpp index f700825..0605fb8 100755 --- a/include/logger/ConsoleLogSink.hpp +++ b/include/logger/ConsoleLogSink.hpp @@ -8,7 +8,7 @@ class ConsoleLogSink : public LogSink public: ConsoleLogSink( const LogLevel level ) : LogSink( level ) { } - void log( const LogLevel level, const std::string &msg ); + DLL_EXPORT virtual void log( const LogLevel level, const std::string &msg ); }; #endif diff --git a/include/logger/FileLogSink.hpp b/include/logger/FileLogSink.hpp index f488a87..d8b1381 100755 --- a/include/logger/FileLogSink.hpp +++ b/include/logger/FileLogSink.hpp @@ -13,7 +13,7 @@ class FileLogSink : public LogSink ~FileLogSink( ); - void log( const LogLevel level, const std::string &msg ); + DLL_EXPORT virtual void log( const LogLevel level, const std::string &msg ); private: std::string m_filename; diff --git a/include/logger/LogSink.hpp b/include/logger/LogSink.hpp index 322e546..0cde9d4 100755 --- a/include/logger/LogSink.hpp +++ b/include/logger/LogSink.hpp @@ -1,6 +1,7 @@ #ifndef __LOGSINK_H #define __LOGSINK_H +#include "Exportable.hpp" #include "Logger.hpp" class LogSink @@ -10,7 +11,7 @@ class LogSink virtual ~LogSink( ) { } - virtual void log( const LogLevel level, const std::string &msg ) = 0; + DLL_EXPORT virtual void log( const LogLevel level, const std::string &msg ) = 0; void setReportingLevel( const LogLevel level ) { m_level = level; } diff --git a/include/logger/Logger.hpp b/include/logger/Logger.hpp index dc514ae..9a84f55 100755 --- a/include/logger/Logger.hpp +++ b/include/logger/Logger.hpp @@ -1,6 +1,7 @@ #ifndef __LOGGER_H #define __LOGGER_H +#include "Exportable.hpp" #include "Singleton.hpp" #include "ScopedPtr.hpp" @@ -29,21 +30,21 @@ class Logger : public Singleton< Logger > public: DECLARE_SINGLETON( Logger ) - void addSink( LogSink *sink ); - void removeSink( LogSink *sink ); - void log( const LogLevel level, const std::string &msg ); + DLL_EXPORT void addSink( LogSink *sink ); + DLL_EXPORT void removeSink( LogSink *sink ); + DLL_EXPORT void log( const LogLevel level, const std::string &msg ); - static std::string toString( const LogLevel level ); - static LogLevel fromString( const std::string &s ); + DLL_EXPORT static std::string toString( const LogLevel level ); + DLL_EXPORT static LogLevel fromString( const std::string &s ); - void openConsoleLog( const LogLevel level ); - void openFileLog( const LogLevel level, const std::string &filename ); - void openSyslog( const LogLevel level, const std::string &ident, const std::string &facility ); - void openWinDbgLog( const LogLevel level ); + DLL_EXPORT void openConsoleLog( const LogLevel level ); + DLL_EXPORT void openFileLog( const LogLevel level, const std::string &filename ); + DLL_EXPORT void openSyslog( const LogLevel level, const std::string &ident, const std::string &facility ); + DLL_EXPORT void openWinDbgLog( const LogLevel level ); protected: - Logger( ); - virtual ~Logger( ); + DLL_EXPORT Logger( ); + DLL_EXPORT virtual ~Logger( ); private: scopedPtr< LoggerImpl > m_impl; @@ -54,9 +55,9 @@ DEFINE_SINGLETON( Logger ) class LogStream : private noncopyable, public std::ostringstream { public: - LogStream( Logger &logger, const LogLevel level ); - ~LogStream( ); - std::ostream &get( ); + DLL_EXPORT LogStream( Logger &logger, const LogLevel level ); + DLL_EXPORT ~LogStream( ); + DLL_EXPORT std::ostream &get( ); private: LogStream( ); diff --git a/include/logger/SyslogLogSink.hpp b/include/logger/SyslogLogSink.hpp index 64e52f1..af0e7ee 100755 --- a/include/logger/SyslogLogSink.hpp +++ b/include/logger/SyslogLogSink.hpp @@ -12,7 +12,7 @@ class SyslogLogSink : public LogSink ~SyslogLogSink( ); - void log( const LogLevel level, const std::string &msg ); + DLL_EXPORT virtual void log( const LogLevel level, const std::string &msg ); static int levelToSyslogLevel( const LogLevel level ); static int facilityFromString( const std::string &facility ); diff --git a/include/logger/WinDbgLogSink.hpp b/include/logger/WinDbgLogSink.hpp index f7caa86..67e13e7 100755 --- a/include/logger/WinDbgLogSink.hpp +++ b/include/logger/WinDbgLogSink.hpp @@ -8,7 +8,7 @@ class WinDbgLogSink : public LogSink public: WinDbgLogSink( const LogLevel level ) : LogSink( level ) { } - void log( const LogLevel level, const std::string &msg ); + DLL_EXPORT virtual void log( const LogLevel level, const std::string &msg ); }; #endif diff --git a/include/util/Exportable.hpp b/include/util/Exportable.hpp index 28ac7ff..a676ae3 100644..100755 --- a/include/util/Exportable.hpp +++ b/include/util/Exportable.hpp @@ -6,8 +6,12 @@ #define SINGLETON_EXPORT #define SINGLETON_EXTERN +#define DLL_EXPORT + #else +#define DLL_EXPORT __declspec(dllexport) + #ifndef SHARED #define SINGLETON_EXPORT __declspec(dllexport) #define SINGLETON_EXTERN diff --git a/include/util/ScopedPtr.hpp b/include/util/ScopedPtr.hpp index 19a41d2..19a41d2 100644..100755 --- a/include/util/ScopedPtr.hpp +++ b/include/util/ScopedPtr.hpp diff --git a/src/Makefile.W32 b/src/Makefile.W32 index 604b8c4..ffcbe27 100755 --- a/src/Makefile.W32 +++ b/src/Makefile.W32 @@ -8,11 +8,15 @@ INCLUDE_CXXFLAGS = \ /D_WIN32_WINNT=0x504 INCLUDE_DIRS = \ - /I. + /I. \ + /I$(TOPDIR)\include\logger \ + /I$(TOPDIR)\include\module \ + /I$(TOPDIR)\include\util INCLUDE_LDFLAGS = \ INCLUDE_LIBS = \ + $(TOPDIR)\src\logger\logger.lib \ Ws2_32.lib LOCAL_STATIC_LIB_OBJS = \ @@ -33,6 +37,11 @@ CPP_BINS = \ !INCLUDE $(TOPDIR)\makefiles\nmake\sub.mk +all: dependencies $(CPP_OBJS) $(CPP_BINS) + +dependencies: + cd logger & $(MAKE) /nologo /f Makefile.w32 all + crawl.exe: crawl.obj $(CPP_OBJS) $(LOCAL_STATIC_LIB): $(LOCAL_STATIC_LIB_OBJS) @@ -52,6 +61,7 @@ local_test: copy_prereq: @-copy "$(ICU_DIR)\bin\icuuc49.dll" . >NUL @-copy "$(ICU_DIR)\bin\icudt49.dll" . >NUL + @-copy "$(TOPDIR)\src\logger\logger.dll" . >NUL run: copy_prereq @-crawl.exe diff --git a/src/logger/Makefile.W32 b/src/logger/Makefile.W32 index ea2e6fc..e985e7a 100755 --- a/src/logger/Makefile.W32 +++ b/src/logger/Makefile.W32 @@ -1,4 +1,4 @@ -TOPDIR = .. +TOPDIR = ..\.. SUBDIRS = @@ -8,56 +8,37 @@ INCLUDE_CXXFLAGS = \ /D_WIN32_WINNT=0x504 INCLUDE_DIRS = \ - /I. + /I. \ + /I$(TOPDIR)\include\logger \ + /I$(TOPDIR)\include\util INCLUDE_LDFLAGS = \ INCLUDE_LIBS = \ Ws2_32.lib -LOCAL_STATIC_LIB_OBJS = \ - win32\errormsg.obj \ - win32\stringutils.obj \ +CPP_OBJS = \ win32\syslog_win32.obj \ Logger.obj \ ConsoleLogSink.obj \ FileLogSink.obj \ SyslogLogSink.obj \ - WinDbgLogSink.obj \ - URL.obj \ - MIMEType.obj \ - SpoolRewindInputStream.obj - -LOCAL_STATIC_LIB = \ - crawler.lib - -CPP_OBJS = \ - $(LOCAL_STATIC_LIB_OBJS) - -CPP_BINS = \ - crawl.exe + WinDbgLogSink.obj + +DYNAMIC_LIB = \ + logger.dll !INCLUDE $(TOPDIR)\makefiles\nmake\sub.mk -crawl.exe: crawl.obj $(CPP_OBJS) - -$(LOCAL_STATIC_LIB): $(LOCAL_STATIC_LIB_OBJS) - $(LINK) /lib /nologo /out:$@ $(STATIC_LDFLAGS) $? +$(DYNAMIC_LIB): $(CPP_OBJS) + $(LINK) /nologo /dll /out:$@ $(LDFLAGS) $(LIBS) $? -local_all: $(LOCAL_STATIC_LIB) $(CPP_BINS) +local_all: $(DYNAMIC_LIB) local_clean: - @-erase $(LOCAL_STATIC_LIB) 2>NUL - @-erase $(CPP_OBJS) win32\*.obj 2>NUL - @-erase test.bat 2>NUL + @-erase $(DYNAMIC_LIB) 2>NUL + @-erase win32\*.obj 2>NUL local_distclean: local_test: - -copy_prereq: - @-copy "$(ICU_DIR)\bin\icuuc49.dll" . >NUL - @-copy "$(ICU_DIR)\bin\icudt49.dll" . >NUL - -run: copy_prereq - @-crawl.exe diff --git a/src/modules/urlfilter/protocol/GNUmakefile b/src/modules/urlfilter/protocol/GNUmakefile index 7151981..53a56df 100644 --- a/src/modules/urlfilter/protocol/GNUmakefile +++ b/src/modules/urlfilter/protocol/GNUmakefile @@ -6,9 +6,9 @@ SUBDIRS = INCLUDE_DIRS = \ -I. -I$(TOPDIR)/src \ - -I$(TOPDIR)/include/logger \ -I$(TOPDIR)/include/util \ - -I$(TOPDIR)/include/module + -I$(TOPDIR)/include/module \ + -I$(TOPDIR)/include/logger INCLUDE_CXXFLAGS = \ diff --git a/src/modules/urlfilter/protocol/Makefile.W32 b/src/modules/urlfilter/protocol/Makefile.W32 index ff1b497..747d714 100755 --- a/src/modules/urlfilter/protocol/Makefile.W32 +++ b/src/modules/urlfilter/protocol/Makefile.W32 @@ -9,12 +9,16 @@ INCLUDE_CXXFLAGS = \ INCLUDE_DIRS = \ /I. \ - /I$(TOPDIR)\src + /I$(TOPDIR)\src \ + /I$(TOPDIR)\include\module \ + /I$(TOPDIR)\include\util \ + /I$(TOPDIR)\include\logger INCLUDE_LDFLAGS = \ INCLUDE_LIBS = \ - $(TOPDIR)\src\crawler.lib + $(TOPDIR)\src\crawler.lib \ + $(TOPDIR)\src\logger\logger.lib DYNAMIC_MODULE = \ mod_urlfilter_protocol.dll diff --git a/src/modules/urlnormalizer/googleurl/Makefile.W32 b/src/modules/urlnormalizer/googleurl/Makefile.W32 index ac94a5c..4cc09c1 100755 --- a/src/modules/urlnormalizer/googleurl/Makefile.W32 +++ b/src/modules/urlnormalizer/googleurl/Makefile.W32 @@ -10,6 +10,8 @@ INCLUDE_CXXFLAGS = \ INCLUDE_DIRS = \ /I. \ /I$(TOPDIR)\src \ + /I$(TOPDIR)\include\module \ + /I$(TOPDIR)\include\util \ /I$(TOPDIR)\googleurl INCLUDE_LDFLAGS = \ diff --git a/src/modules/urlnormalizer/simpleurl/Makefile.W32 b/src/modules/urlnormalizer/simpleurl/Makefile.W32 index 5dc0dba..69e732a 100755 --- a/src/modules/urlnormalizer/simpleurl/Makefile.W32 +++ b/src/modules/urlnormalizer/simpleurl/Makefile.W32 @@ -9,7 +9,9 @@ INCLUDE_CXXFLAGS = \ INCLUDE_DIRS = \ /I. \ - /I$(TOPDIR)\src + /I$(TOPDIR)\src \ + /I$(TOPDIR)\include\module \ + /I$(TOPDIR)\include\util INCLUDE_LDFLAGS = \ diff --git a/tests/logger/Makefile.W32 b/tests/logger/Makefile.W32 index d9dd951..e499e28 100755 --- a/tests/logger/Makefile.W32 +++ b/tests/logger/Makefile.W32 @@ -9,12 +9,15 @@ INCLUDE_CXXFLAGS = \ INCLUDE_DIRS = \ /I. \ - /I$(TOPDIR)\src + /I$(TOPDIR)\src \ + /I$(TOPDIR)\include\logger \ + /I$(TOPDIR)\include\util INCLUDE_LDFLAGS = \ INCLUDE_LIBS = \ $(TOPDIR)\src\crawler.lib \ + $(TOPDIR)\src\logger\logger.lib \ Ws2_32.lib TEST_CPP_BINS = \ diff --git a/tests/logger/exec_test.cmd b/tests/logger/exec_test.cmd index 4d186b7..1203382 100755 --- a/tests/logger/exec_test.cmd +++ b/tests/logger/exec_test.cmd @@ -3,11 +3,12 @@ set BINARY=%1
set TITLE=%2
+copy ..\..\src\logger\logger.dll .
%BINARY% >%BINARY%.OUT 2>%BINARY%.ERR
..\..\utils\win32\dos2unix <%BINARY%.OUT >%BINARY%.RES
..\..\utils\win32\dos2unix <%BINARY%.ERR >%BINARY%.RES
erase /q %BINARY%.OUT
-echo n | comp %BINARY%.MUST %BINARY%.RES > %BINARY%.DIFF 2>NUL
+echo n | comp %BINARY%.MUST.WIN32 %BINARY%.RES > %BINARY%.DIFF 2>NUL
if ERRORLEVEL 1 GOTO FAIL
echo %BINARY%: %TITLE%.. OK
goto END
diff --git a/tests/logger/test1.MUST.WIN32 b/tests/logger/test1.MUST.WIN32 new file mode 100644 index 0000000..0752988 --- /dev/null +++ b/tests/logger/test1.MUST.WIN32 @@ -0,0 +1,18 @@ +FATAL: fatal error +CRITICAL: critical error +ERROR: error +WARNING: warning +NOTICE: notice +FATAL: fatal error +CRITICAL: critical error +ERROR: error +WARNING: warning +NOTICE: notice +INFO: info +DEBUG: debug +DEBUG1: debug level 1 +DEBUG2: debug level 2 +DEBUG3: debug level 3 +DEBUG4: debug level 4 +WARNING: Unknown log level 'bla'. Using INFO level as default. +INFO: the level is INFO |