From 13fc9a7da5111f4ddba942d3c6b6b8654ce395d6 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Thu, 6 Sep 2012 22:18:23 +0200 Subject: more splitting into libcrawl, crawl binary moved more public header to 'include' changed approach for dynamic linking on Windows --- include/logger/ConsoleLogSink.hpp | 2 +- include/logger/FileLogSink.hpp | 2 +- include/logger/LogSink.hpp | 4 ++-- include/logger/Logger.hpp | 32 +++++++++++++++----------------- include/logger/LoggerExportable.hpp | 26 ++++++++++++++++++++++++++ include/logger/SyslogLogSink.hpp | 6 +++--- include/logger/WinDbgLogSink.hpp | 2 +- 7 files changed, 49 insertions(+), 25 deletions(-) create mode 100755 include/logger/LoggerExportable.hpp (limited to 'include/logger') diff --git a/include/logger/ConsoleLogSink.hpp b/include/logger/ConsoleLogSink.hpp index 4380df8..75dea72 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_VISIBLE virtual void log( const LogLevel level, const std::string &msg ); + LOGGER_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 0acb6b9..5ab9b86 100755 --- a/include/logger/FileLogSink.hpp +++ b/include/logger/FileLogSink.hpp @@ -13,7 +13,7 @@ class FileLogSink : public LogSink ~FileLogSink( ); - DLL_VISIBLE virtual void log( const LogLevel level, const std::string &msg ); + LOGGER_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 4d07df0..06113f9 100755 --- a/include/logger/LogSink.hpp +++ b/include/logger/LogSink.hpp @@ -1,7 +1,7 @@ #ifndef __LOGSINK_H #define __LOGSINK_H -#include "Exportable.hpp" +#include "LoggerExportable.hpp" #include "Logger.hpp" class LogSink @@ -11,7 +11,7 @@ class LogSink virtual ~LogSink( ) { } - DLL_VISIBLE virtual void log( const LogLevel level, const std::string &msg ) = 0; + LOGGER_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 f0c0012..451ca45 100755 --- a/include/logger/Logger.hpp +++ b/include/logger/Logger.hpp @@ -1,7 +1,7 @@ #ifndef __LOGGER_H #define __LOGGER_H -#include "Exportable.hpp" +#include "LoggerExportable.hpp" #include "Singleton.hpp" #include "ScopedPtr.hpp" @@ -30,34 +30,32 @@ class Logger : public Singleton< Logger > public: DECLARE_SINGLETON( Logger ) - DLL_VISIBLE void addSink( LogSink *sink ); - DLL_VISIBLE void removeSink( LogSink *sink ); - DLL_VISIBLE void log( const LogLevel level, const std::string &msg ); + LOGGER_DLL_VISIBLE void addSink( LogSink *sink ); + LOGGER_DLL_VISIBLE void removeSink( LogSink *sink ); + LOGGER_DLL_VISIBLE void log( const LogLevel level, const std::string &msg ); - DLL_VISIBLE static std::string toString( const LogLevel level ); - DLL_VISIBLE static LogLevel fromString( const std::string &s ); + LOGGER_DLL_VISIBLE static std::string toString( const LogLevel level ); + LOGGER_DLL_VISIBLE static LogLevel fromString( const std::string &s ); - 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 ); + LOGGER_DLL_VISIBLE void openConsoleLog( const LogLevel level ); + LOGGER_DLL_VISIBLE void openFileLog( const LogLevel level, const std::string &filename ); + LOGGER_DLL_VISIBLE void openSyslog( const LogLevel level, const std::string &ident, const std::string &facility ); + LOGGER_DLL_VISIBLE void openWinDbgLog( const LogLevel level ); protected: - DLL_VISIBLE Logger( ); - DLL_VISIBLE virtual ~Logger( ); + LOGGER_DLL_VISIBLE Logger( ); + LOGGER_DLL_VISIBLE virtual ~Logger( ); private: scopedPtr< LoggerImpl > m_impl; }; -DEFINE_SINGLETON( Logger ) - class LogStream : private noncopyable, public std::ostringstream { public: - DLL_VISIBLE LogStream( Logger &logger, const LogLevel level ); - DLL_VISIBLE ~LogStream( ); - DLL_VISIBLE std::ostream &get( ); + LOGGER_DLL_VISIBLE LogStream( Logger &logger, const LogLevel level ); + LOGGER_DLL_VISIBLE ~LogStream( ); + LOGGER_DLL_VISIBLE std::ostream &get( ); private: LogStream( ); diff --git a/include/logger/LoggerExportable.hpp b/include/logger/LoggerExportable.hpp new file mode 100755 index 0000000..0445213 --- /dev/null +++ b/include/logger/LoggerExportable.hpp @@ -0,0 +1,26 @@ +#ifndef __LOGGER_EXPORTABLE_H +#define __LOGGER_EXPORTABLE_H + +#ifndef _WIN32 + +#define LOGGER_DLL_VISIBLE + +#else + +#ifdef SHARED + +#ifdef BUILDING_LOGGER +#define LOGGER_DLL_VISIBLE __declspec(dllexport) +#else +#define LOGGER_DLL_VISIBLE __declspec(dllimport) +#endif + +#else + +#define LOGGER_DLL_VISIBLE + +#endif // BUILDING_LOGGER + +#endif // _WIN32 + +#endif diff --git a/include/logger/SyslogLogSink.hpp b/include/logger/SyslogLogSink.hpp index f5824a6..058e126 100755 --- a/include/logger/SyslogLogSink.hpp +++ b/include/logger/SyslogLogSink.hpp @@ -12,10 +12,10 @@ class SyslogLogSink : public LogSink ~SyslogLogSink( ); - DLL_VISIBLE virtual void log( const LogLevel level, const std::string &msg ); + LOGGER_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 ); + LOGGER_DLL_VISIBLE static int levelToSyslogLevel( const LogLevel level ); + LOGGER_DLL_VISIBLE static int facilityFromString( const std::string &facility ); private: std::string m_ident; diff --git a/include/logger/WinDbgLogSink.hpp b/include/logger/WinDbgLogSink.hpp index d073cdc..2fe8a43 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_VISIBLE virtual void log( const LogLevel level, const std::string &msg ); + LOGGER_DLL_VISIBLE virtual void log( const LogLevel level, const std::string &msg ); }; #endif -- cgit v1.2.3-54-g00ecf