diff options
author | Andreas Baumann <abaumann@yahoo.com> | 2012-09-06 10:25:57 +0200 |
---|---|---|
committer | Andreas Baumann <abaumann@yahoo.com> | 2012-09-06 10:25:57 +0200 |
commit | f5c586f7231f7e033c5528bcefea357e4e64441c (patch) | |
tree | 4d039e54c77bdb84a1cb79b56db7b62bccdd43d8 | |
parent | a29c464aa72d46cc956ac2752a2518526c499716 (diff) | |
download | crawler-f5c586f7231f7e033c5528bcefea357e4e64441c.tar.gz crawler-f5c586f7231f7e033c5528bcefea357e4e64441c.tar.bz2 |
first properly working logger on Windows (singleton dll issue)
-rwxr-xr-x | include/logger/ConsoleLogSink.hpp | 2 | ||||
-rwxr-xr-x | include/logger/FileLogSink.hpp | 2 | ||||
-rwxr-xr-x | include/logger/LogSink.hpp | 2 | ||||
-rwxr-xr-x | include/logger/Logger.hpp | 28 | ||||
-rwxr-xr-x | include/logger/SyslogLogSink.hpp | 2 | ||||
-rwxr-xr-x | include/logger/WinDbgLogSink.hpp | 2 | ||||
-rwxr-xr-x | include/util/Exportable.hpp | 23 | ||||
-rwxr-xr-x | include/util/NonCopyable.hpp | 2 | ||||
-rwxr-xr-x | include/util/ScopedPtr.hpp | 2 | ||||
-rwxr-xr-x | include/util/Singleton.hpp | 14 | ||||
-rwxr-xr-x | src/logger/Makefile.W32 | 3 | ||||
-rwxr-xr-x | src/modules/deduper/null/Makefile.W32 | 4 | ||||
-rwxr-xr-x | src/modules/fetcher/file/Makefile.W32 | 4 | ||||
-rwxr-xr-x | src/modules/fetcher/winhttp/Makefile.W32 | 6 | ||||
-rwxr-xr-x | src/modules/frontier/memory/Makefile.W32 | 8 | ||||
-rwxr-xr-x | src/modules/processor/htmllinkextract/Makefile.W32 | 3 | ||||
-rwxr-xr-x | src/modules/urlfilter/chain/Makefile.W32 | 5 | ||||
-rwxr-xr-x | src/modules/urlfilter/host/Makefile.W32 | 8 | ||||
-rwxr-xr-x | src/modules/urlseen/memory/Makefile.W32 | 8 | ||||
-rwxr-xr-x | tests/modules/testmod/Makefile.W32 | 2 | ||||
-rwxr-xr-x | tests/utils/Makefile.W32 | 6 | ||||
-rwxr-xr-x[-rw-r--r--] | tests/utils/test3.cpp | 4 |
22 files changed, 91 insertions, 49 deletions
diff --git a/include/logger/ConsoleLogSink.hpp b/include/logger/ConsoleLogSink.hpp index 0605fb8..4380df8 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 ) { } - DLL_EXPORT virtual void log( const LogLevel level, const std::string &msg ); + DLL_VISIBLE virtual void log( const LogLevel level, const std::string &msg ); }; #endif diff --git a/include/logger/FileLogSink.hpp b/include/logger/FileLogSink.hpp index d8b1381..0acb6b9 100755 --- a/include/logger/FileLogSink.hpp +++ b/include/logger/FileLogSink.hpp @@ -13,7 +13,7 @@ class FileLogSink : public LogSink ~FileLogSink( ); - DLL_EXPORT virtual void log( const LogLevel level, const std::string &msg ); + DLL_VISIBLE 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 0cde9d4..4d07df0 100755 --- a/include/logger/LogSink.hpp +++ b/include/logger/LogSink.hpp @@ -11,7 +11,7 @@ class LogSink virtual ~LogSink( ) { } - DLL_EXPORT virtual void log( const LogLevel level, const std::string &msg ) = 0; + DLL_VISIBLE 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 9a84f55..f0c0012 100755 --- a/include/logger/Logger.hpp +++ b/include/logger/Logger.hpp @@ -30,21 +30,21 @@ class Logger : public Singleton< Logger > public: DECLARE_SINGLETON( Logger ) - DLL_EXPORT void addSink( LogSink *sink ); - DLL_EXPORT void removeSink( LogSink *sink ); - DLL_EXPORT void log( const LogLevel level, const std::string &msg ); + DLL_VISIBLE void addSink( LogSink *sink ); + DLL_VISIBLE void removeSink( LogSink *sink ); + DLL_VISIBLE void log( const LogLevel level, const std::string &msg ); - DLL_EXPORT static std::string toString( const LogLevel level ); - DLL_EXPORT static LogLevel fromString( const std::string &s ); + DLL_VISIBLE static std::string toString( const LogLevel level ); + DLL_VISIBLE static LogLevel fromString( const std::string &s ); - 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 ); + DLL_VISIBLE void openConsoleLog( const LogLevel level ); + DLL_VISIBLE void openFileLog( const LogLevel level, const std::string &filename ); + DLL_VISIBLE void openSyslog( const LogLevel level, const std::string &ident, const std::string &facility ); + DLL_VISIBLE void openWinDbgLog( const LogLevel level ); protected: - DLL_EXPORT Logger( ); - DLL_EXPORT virtual ~Logger( ); + DLL_VISIBLE Logger( ); + DLL_VISIBLE virtual ~Logger( ); private: scopedPtr< LoggerImpl > m_impl; @@ -55,9 +55,9 @@ DEFINE_SINGLETON( Logger ) class LogStream : private noncopyable, public std::ostringstream { public: - DLL_EXPORT LogStream( Logger &logger, const LogLevel level ); - DLL_EXPORT ~LogStream( ); - DLL_EXPORT std::ostream &get( ); + DLL_VISIBLE LogStream( Logger &logger, const LogLevel level ); + DLL_VISIBLE ~LogStream( ); + DLL_VISIBLE std::ostream &get( ); private: LogStream( ); diff --git a/include/logger/SyslogLogSink.hpp b/include/logger/SyslogLogSink.hpp index af0e7ee..f5824a6 100755 --- a/include/logger/SyslogLogSink.hpp +++ b/include/logger/SyslogLogSink.hpp @@ -12,7 +12,7 @@ class SyslogLogSink : public LogSink ~SyslogLogSink( ); - DLL_EXPORT virtual void log( const LogLevel level, const std::string &msg ); + DLL_VISIBLE 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 67e13e7..d073cdc 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 ) { } - DLL_EXPORT virtual void log( const LogLevel level, const std::string &msg ); + DLL_VISIBLE virtual void log( const LogLevel level, const std::string &msg ); }; #endif diff --git a/include/util/Exportable.hpp b/include/util/Exportable.hpp index a676ae3..fc8269f 100755 --- a/include/util/Exportable.hpp +++ b/include/util/Exportable.hpp @@ -3,21 +3,22 @@ #ifndef _WIN32 -#define SINGLETON_EXPORT -#define SINGLETON_EXTERN - -#define DLL_EXPORT +#define DLL_VISIBLE +#define DLL_EXTERN #else -#define DLL_EXPORT __declspec(dllexport) - -#ifndef SHARED -#define SINGLETON_EXPORT __declspec(dllexport) -#define SINGLETON_EXTERN +#ifdef NODLL +#define DLL_VISIBLE +#define DLL_EXTERN #else -#define SINGLETON_EXPORT __declspec(dllimport) -#define SINGLETON_EXTERN extern +#ifdef SHARED +#define DLL_VISIBLE __declspec(dllexport) +#define DLL_EXTERN +#else +#define DLL_VISIBLE __declspec(dllimport) +#define DLL_EXTERN +#endif #endif #endif // _WIN32 diff --git a/include/util/NonCopyable.hpp b/include/util/NonCopyable.hpp index 44d1a93..99804d2 100755 --- a/include/util/NonCopyable.hpp +++ b/include/util/NonCopyable.hpp @@ -6,7 +6,7 @@ namespace __dont_touch { -class SINGLETON_EXPORT noncopyable +class DLL_VISIBLE noncopyable { protected: noncopyable( ) { } diff --git a/include/util/ScopedPtr.hpp b/include/util/ScopedPtr.hpp index 19a41d2..991409d 100755 --- a/include/util/ScopedPtr.hpp +++ b/include/util/ScopedPtr.hpp @@ -4,7 +4,7 @@ #include "NonCopyable.hpp" template< typename T > -class scopedPtr : private noncopyable +class DLL_VISIBLE scopedPtr : private noncopyable { public: explicit scopedPtr( T *p = 0 ) : m_p( p ) { } diff --git a/include/util/Singleton.hpp b/include/util/Singleton.hpp index 1bfb460..f291435 100755 --- a/include/util/Singleton.hpp +++ b/include/util/Singleton.hpp @@ -10,17 +10,23 @@ #include <stdexcept> #define DECLARE_SINGLETON( T ) \ - friend class scopedPtr< T >; \ - friend class Singleton< T >; + friend class Singleton< T >; \ + friend class scopedPtr< T >; + +#define DEFINE_SINGLETON( T ) + +#if 0 +#define DECLARE_SINGLETON( T ) \ #define DEFINE_SINGLETON( T ) \ - SINGLETON_EXTERN template class SINGLETON_EXPORT Singleton< T >; + DLL_EXTERN template class DLL_VISIBLE Singleton< T >; +#endif template< class T > class Singleton : private noncopyable { public: - static T& instance( ) + DLL_VISIBLE static T& instance( ) { if( destroyed ) { onDeadReference( ); diff --git a/src/logger/Makefile.W32 b/src/logger/Makefile.W32 index e985e7a..3f9352d 100755 --- a/src/logger/Makefile.W32 +++ b/src/logger/Makefile.W32 @@ -5,7 +5,8 @@ SUBDIRS = !INCLUDE $(TOPDIR)\makefiles\nmake\platform.mk INCLUDE_CXXFLAGS = \ - /D_WIN32_WINNT=0x504 + /D_WIN32_WINNT=0x504 \ + /DSHARED INCLUDE_DIRS = \ /I. \ diff --git a/src/modules/deduper/null/Makefile.W32 b/src/modules/deduper/null/Makefile.W32 index dc033ce..e01235f 100755 --- a/src/modules/deduper/null/Makefile.W32 +++ b/src/modules/deduper/null/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/src/modules/fetcher/file/Makefile.W32 b/src/modules/fetcher/file/Makefile.W32 index ddc942d..3203d6d 100755 --- a/src/modules/fetcher/file/Makefile.W32 +++ b/src/modules/fetcher/file/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/src/modules/fetcher/winhttp/Makefile.W32 b/src/modules/fetcher/winhttp/Makefile.W32 index 5ef2a42..b46aa88 100755 --- a/src/modules/fetcher/winhttp/Makefile.W32 +++ b/src/modules/fetcher/winhttp/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\logger\logger.lib \ WinHttp.lib DYNAMIC_MODULE = \ diff --git a/src/modules/frontier/memory/Makefile.W32 b/src/modules/frontier/memory/Makefile.W32 index 903be8c..b44d95f 100755 --- a/src/modules/frontier/memory/Makefile.W32 +++ b/src/modules/frontier/memory/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_frontier_memory.dll diff --git a/src/modules/processor/htmllinkextract/Makefile.W32 b/src/modules/processor/htmllinkextract/Makefile.W32 index ea2cede..8229f18 100755 --- a/src/modules/processor/htmllinkextract/Makefile.W32 +++ b/src/modules/processor/htmllinkextract/Makefile.W32 @@ -10,6 +10,9 @@ INCLUDE_CXXFLAGS = \ INCLUDE_DIRS = \ /I. \ /I$(TOPDIR)\src \ + /I$(TOPDIR)\include\module \ + /I$(TOPDIR)\include\util \ + /I$(TOPDIR)\include\logger \ /I$(TOPDIR)\streamhtmlparser INCLUDE_LDFLAGS = \ diff --git a/src/modules/urlfilter/chain/Makefile.W32 b/src/modules/urlfilter/chain/Makefile.W32 index ec7e496..5a766ab 100755 --- a/src/modules/urlfilter/chain/Makefile.W32 +++ b/src/modules/urlfilter/chain/Makefile.W32 @@ -9,7 +9,10 @@ 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 = \ diff --git a/src/modules/urlfilter/host/Makefile.W32 b/src/modules/urlfilter/host/Makefile.W32 index 8c5cfdb..3b99125 100755 --- a/src/modules/urlfilter/host/Makefile.W32 +++ b/src/modules/urlfilter/host/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_host.dll diff --git a/src/modules/urlseen/memory/Makefile.W32 b/src/modules/urlseen/memory/Makefile.W32 index 6cd075e..c01f800 100755 --- a/src/modules/urlseen/memory/Makefile.W32 +++ b/src/modules/urlseen/memory/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_urlseen_memory.dll diff --git a/tests/modules/testmod/Makefile.W32 b/tests/modules/testmod/Makefile.W32 index e01c220..77d16cb 100755 --- a/tests/modules/testmod/Makefile.W32 +++ b/tests/modules/testmod/Makefile.W32 @@ -10,6 +10,8 @@ INCLUDE_CXXFLAGS = \ INCLUDE_DIRS = \ /I. \ /I$(TOPDIR)\src \ + /I$(TOPDIR)\include\module \ + /I$(TOPDIR)\include\util \ /I.. INCLUDE_LDFLAGS = \ diff --git a/tests/utils/Makefile.W32 b/tests/utils/Makefile.W32 index 6f18d9c..03ea7ae 100755 --- a/tests/utils/Makefile.W32 +++ b/tests/utils/Makefile.W32 @@ -5,11 +5,13 @@ SUBDIRS = !INCLUDE $(TOPDIR)\makefiles\nmake\platform.mk INCLUDE_CXXFLAGS = \ - /D_WIN32_WINNT=0x504 + /D_WIN32_WINNT=0x504 \ + /DNODLL INCLUDE_DIRS = \ /I. \ - /I$(TOPDIR)\src + /I$(TOPDIR)\src \ + /I$(TOPDIR)\include\util INCLUDE_LDFLAGS = \ diff --git a/tests/utils/test3.cpp b/tests/utils/test3.cpp index 489276b..2a9a37f 100644..100755 --- a/tests/utils/test3.cpp +++ b/tests/utils/test3.cpp @@ -8,6 +8,8 @@ using namespace std; class Logger : public Singleton< Logger > { public: + DECLARE_SINGLETON( Logger ) + void log( string s ) { cout << s << endl; @@ -28,6 +30,8 @@ class Logger : public Singleton< Logger > } }; +DEFINE_SINGLETON( Logger ) + /* this works, and two loggers can coexist, but they have different type class DerivedLogger : public Logger { |