Commit e453af33 authored by Samuel Debionne's avatar Samuel Debionne Committed by operator for beamline

Use CMake generators expression to add LIMA_NO_DEBUG definition.

Fix a merge mistake when rebasing from master.
Reintroduce DevSink and adjust Event accordingly.
parent 7e0c8c69
Pipeline #7245 passed with stages
in 9 minutes and 52 seconds
......@@ -60,11 +60,6 @@ endif()
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
include(LimaTools)
# Logging, disable trace in Release builds
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-DLIMA_NO_DEBUG)
endif()
# Import pthread
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package(Threads REQUIRED)
......@@ -264,9 +259,7 @@ if(LIMA_ENABLE_SPS_IMAGE)
endif()
# Set LIMA_NO_DEBUG if the build type is not debug
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_definitions(limacore PUBLIC LIMA_NO_DEBUG)
endif()
target_compile_definitions(limacore PUBLIC $<$<NOT:$<CONFIG:DEBUG>>:LIMA_NO_DEBUG>)
# add all include paths coming from saving format options
target_include_directories(limacore PRIVATE ${extra_includes} ${saving_includes})
......
......@@ -236,15 +236,15 @@ std::ostream& operator <<(std::ostream& os,
class LIMACORE_API DebProxy
{
public:
public:
DebProxy();
DebProxy(DebObj *deb_obj, DebType type, ConstStr funct_name,
ConstStr file_name, int line_nr);
DebProxy(DebObj *deb_obj, DebType type, ConstStr funct_name,
ConstStr file_name, int line_nr);
DebProxy(const DebProxy& p);
~DebProxy();
template <class T>
const DebProxy& operator <<(const T& o) const;
template <class T>
const DebProxy& operator <<(const T& o) const;
bool isActive() const;
......@@ -498,8 +498,6 @@ inline DebProxy DebObj::write(DebType type, ConstStr file_name, int line_nr)
* debug macros
*------------------------------------------------------------------*/
#define DEB_NOP() do {} while (0)
#define DEB_GLOBAL_NAMESPC(mod, name_space) \
inline lima::DebParams& getDebParams() \
{ \
......@@ -588,30 +586,42 @@ inline DebProxy DebObj::write(DebType type, ConstStr file_name, int line_nr)
#define DEB_CHECK_ANY(type) deb.checkAny(type)
#define DEB_EVENT(event) DEB_MSG((event).getDebType())
#else // LIMA_NO_DEBUG
#define DEB_GLOBAL_FUNCT() DEB_NOP()
#define DEB_CONSTRUCTOR() DEB_NOP()
#define DEB_DESTRUCTOR() DEB_NOP()
#define DEB_MEMBER_FUNCT() DEB_NOP()
// Mock implementation of the DebProxy
class LIMACORE_API DebSink
{
public:
DebSink() {};
template <class T>
const DebSink& operator <<(const T&) const {return *this;}
};
#define DEB_GLOBAL_FUNCT()
#define DEB_CONSTRUCTOR()
#define DEB_DESTRUCTOR()
#define DEB_MEMBER_FUNCT()
#define DEB_PTR() NULL
#define DEB_FROM_PTR(deb_ptr) DEB_NOP()
#define DEB_STATIC_FUNCT() DEB_NOP()
#define DEB_SET_OBJ_NAME(n) DEB_NOP()
#define DEB_FROM_PTR(deb_ptr)
#define DEB_STATIC_FUNCT()
#define DEB_SET_OBJ_NAME(n)
#define DEB_OUT_MSG(type) \
#define DEB_MSG(type) \
DebProxy(NULL, type, __FUNCTION__, __FILE__, __LINE__)
#define DEB_NO_MSG() \
DebProxy()
DebSink()
#define DEB_FATAL() DEB_OUT_MSG(lima::DebTypeFatal)
#define DEB_ERROR() DEB_OUT_MSG(lima::DebTypeError)
#define DEB_WARNING() DEB_OUT_MSG(lima::DebTypeWarning)
#define DEB_FATAL() DEB_MSG(lima::DebTypeFatal)
#define DEB_ERROR() DEB_MSG(lima::DebTypeError)
#define DEB_WARNING() DEB_MSG(lima::DebTypeWarning)
#define DEB_TRACE() DEB_NO_MSG()
#define DEB_PARAM() DEB_NO_MSG()
#define DEB_RETURN() DEB_NO_MSG()
#define DEB_ALWAYS() DEB_OUT_MSG(lima::DebTypeAlways)
#define DEB_ALWAYS() DEB_MSG(lima::DebTypeAlways)
#define DEB_OBJ_NAME(o) NULL
......@@ -623,6 +633,8 @@ inline DebProxy DebObj::write(DebType type, ConstStr file_name, int line_nr)
(((type) == lima::DebTypeFatal) || ((type) == lima::DebTypeError) || \
((type) == lima::DebTypeWarning) || ((type) == lima::DebTypeAlways))
#define DEB_EVENT(event) DEB_MSG((event).getDebType())
#endif // LIMA_NO_DEBUG
#define DEB_HEX(x) DebHex(x)
......
......@@ -24,6 +24,7 @@
#include "lima/LimaCompatibility.h"
#include "lima/Timestamp.h"
#include "lima/Debug.h"
#include <string>
#include <ostream>
......@@ -60,13 +61,11 @@ class LIMACORE_API Event
Event(Layer l, Severity s, Domain d, Code c,const std::string &e);
virtual ~Event();
virtual std::string getMsgStr();
virtual std::string getMsgStr() const;
DebProxy getDebug(DebObj *deb) const;
DebType getDebType() const;
};
#define DEB_EVENT(event) (event).getDebug(DEB_PTR())
std::ostream& operator <<(std::ostream& os, const Event& event);
......
......@@ -44,7 +44,7 @@ Event::~Event()
{
}
string Event::getMsgStr()
string Event::getMsgStr() const
{
ostringstream os;
......@@ -100,26 +100,23 @@ string Event::getMsgStr()
return os.str();
}
DebProxy Event::getDebug(DebObj *deb_obj) const
DebType Event::getDebType() const
{
DEB_FROM_PTR(deb_obj);
switch (severity) {
case Event::Fatal:
return DEB_FATAL();
return DebTypeFatal;
case Event::Error:
return DEB_ERROR();
return DebTypeError;
case Event::Warning:
return DEB_WARNING();
return DebTypeWarning;
default:
return DEB_TRACE();
return DebTypeTrace;
}
}
ostream& lima::operator <<(ostream& os, const Event& event)
{
Event& noconst_event = const_cast<Event&>(event);
return os << "<" << noconst_event.getMsgStr() << ">";
return os << "<" << event.getMsgStr() << ">";
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment