Mercurial > hg > orthanc
changeset 3996:c2b9a7a1c74a
ORTHANC_FRAMEWORK_BUILDING_PLUGIN
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 05 Jun 2020 18:26:01 +0200 |
parents | 1f405a3fdeca |
children | febe25d03f08 |
files | CMakeLists.txt Core/Logging.cpp Core/Logging.h Core/OrthancFramework.h |
diffstat | 4 files changed, 45 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/CMakeLists.txt Fri Jun 05 18:08:17 2020 +0200 +++ b/CMakeLists.txt Fri Jun 05 18:26:01 2020 +0200 @@ -251,6 +251,7 @@ add_definitions( + -DORTHANC_FRAMEWORK_BUILDING_PLUGIN=0 -DORTHANC_BUILD_UNIT_TESTS=1 -DORTHANC_ENABLE_LOGGING_PLUGIN=0
--- a/Core/Logging.cpp Fri Jun 05 18:08:17 2020 +0200 +++ b/Core/Logging.cpp Fri Jun 05 18:26:01 2020 +0200 @@ -167,7 +167,7 @@ globalTraceLogFunc = traceLogFunc; } - InternalLogger::InternalLogger(InternalLevel level, + InternalLogger::InternalLogger(Level level, const char* file /* ignored */, int line /* ignored */) : level_(level) @@ -180,15 +180,15 @@ switch (level_) { - case InternalLevel_ERROR: + case Level_ERROR: globalErrorLogFunc(message.c_str()); break; - case InternalLevel_WARNING: + case Level_WARNING: globalWarningLogFunc(message.c_str()); break; - case InternalLevel_INFO: + case Level_INFO: if (globalVerbose_) { globalInfoLogFunc(message.c_str()); @@ -196,7 +196,7 @@ } break; - case InternalLevel_TRACE: + case Level_TRACE: if (globalTrace_) { globalTraceLogFunc(message.c_str()); @@ -310,7 +310,7 @@ context_ = reinterpret_cast<OrthancPluginContext*>(context); } - InternalLogger::InternalLogger(InternalLevel level, + InternalLogger::InternalLogger(Level level, const char* file /* ignored */, int line /* ignored */) : level_(level) @@ -324,19 +324,19 @@ { switch (level_) { - case InternalLevel_ERROR: + case Level_ERROR: context_->InvokeService(context_, _OrthancPluginService_LogError, message.c_str()); break; - case InternalLevel_WARNING: + case Level_WARNING: context_->InvokeService(context_, _OrthancPluginService_LogWarning, message.c_str()); break; - case InternalLevel_INFO: + case Level_INFO: context_->InvokeService(context_, _OrthancPluginService_LogInfo, message.c_str()); break; - case InternalLevel_TRACE: + case Level_TRACE: // Not used by plugins break;
--- a/Core/Logging.h Fri Jun 05 18:08:17 2020 +0200 +++ b/Core/Logging.h Fri Jun 05 18:26:01 2020 +0200 @@ -64,6 +64,14 @@ { namespace Logging { + enum Level + { + Level_ERROR, + Level_WARNING, + Level_INFO, + Level_TRACE + }; + #if ORTHANC_ENABLE_LOGGING_PLUGIN == 1 // "pluginContext" must be of type "OrthancPluginContext" ORTHANC_PUBLIC void Initialize(void* pluginContext); @@ -124,30 +132,22 @@ # include <boost/noncopyable.hpp> # define LOG(level) ::Orthanc::Logging::InternalLogger \ - (::Orthanc::Logging::InternalLevel_ ## level, __FILE__, __LINE__) + (::Orthanc::Logging::Level_ ## level, __FILE__, __LINE__) # define VLOG(level) ::Orthanc::Logging::InternalLogger \ - (::Orthanc::Logging::InternalLevel_TRACE, __FILE__, __LINE__) + (::Orthanc::Logging::Level_TRACE, __FILE__, __LINE__) namespace Orthanc { namespace Logging { - enum InternalLevel - { - InternalLevel_ERROR, - InternalLevel_WARNING, - InternalLevel_INFO, - InternalLevel_TRACE - }; - class ORTHANC_PUBLIC InternalLogger : public boost::noncopyable { private: - InternalLevel level_; + Level level_; std::stringstream messageStream_; public: - InternalLogger(InternalLevel level, + InternalLogger(Level level, const char* file, int line);
--- a/Core/OrthancFramework.h Fri Jun 05 18:08:17 2020 +0200 +++ b/Core/OrthancFramework.h Fri Jun 05 18:26:01 2020 +0200 @@ -41,23 +41,33 @@ #ifndef __ORTHANC_FRAMEWORK_H #define __ORTHANC_FRAMEWORK_H +#if !defined(ORTHANC_FRAMEWORK_BUILDING_PLUGIN) +# error Macro ORTHANC_FRAMEWORK_BUILDING_PLUGIN must be defined +#endif + /** * It is implied that if this file is used, we're building the Orthanc - * framework (not using it): We don't use the common "BUILDING_DLL" + * framework (not using it as a shared library): We don't use the + * common "BUILDING_DLL" * construction. https://gcc.gnu.org/wiki/Visibility **/ -#if defined(_WIN32) || defined (__CYGWIN__) -# define ORTHANC_PUBLIC __declspec(dllexport) -# define ORTHANC_LOCAL +#if ORTHANC_FRAMEWORK_BUILDING_PLUGIN == 0 +# if defined(_WIN32) || defined (__CYGWIN__) +# define ORTHANC_PUBLIC __declspec(dllexport) +# define ORTHANC_LOCAL +# else +# if __GNUC__ >= 4 +# define ORTHANC_PUBLIC __attribute__((visibility ("default"))) +# define ORTHANC_LOCAL __attribute__((visibility ("hidden"))) +# else +# define ORTHANC_PUBLIC +# define ORTHANC_LOCAL +# pragma warning Unknown dynamic link import/export semantics +# endif +# endif #else -# if __GNUC__ >= 4 -# define ORTHANC_PUBLIC __attribute__((visibility ("default"))) -# define ORTHANC_LOCAL __attribute__((visibility ("hidden"))) -# else -# define ORTHANC_PUBLIC -# define ORTHANC_LOCAL -# pragma warning Unknown dynamic link import/export semantics -# endif +# define ORTHANC_PUBLIC +# define ORTHANC_LOCAL #endif #endif /* __ORTHANC_FRAMEWORK_H */