From 95215e438d27f4ee715a1bf33fa491d89cb98f15 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Wed, 30 Apr 2014 22:18:00 +0200 Subject: [PATCH] [DEV] change log system --- esvg/Path.cpp | 2 +- esvg/debug.cpp | 6 +++++- esvg/debug.h | 48 ++++++++++++++++++++++++++++++++++++------------ 3 files changed, 42 insertions(+), 14 deletions(-) diff --git a/esvg/Path.cpp b/esvg/Path.cpp index 3c9392a..fa79a4b 100644 --- a/esvg/Path.cpp +++ b/esvg/Path.cpp @@ -81,7 +81,7 @@ bool esvg::Path::parse(exml::Element * _element, agg::trans_affine& _parentTrans SVG_ERROR("(l "<<_element->getPos()<<") path: missing 'p' attribute"); return false; } - SVG_VERBOSE("Parse Path : \"" << elementXML << "\""); + SVG_VERBOSE("Parse Path : \"" << elementXML1 << "\""); char command; std::vector listDot; diff --git a/esvg/debug.cpp b/esvg/debug.cpp index a279c6a..02da2a3 100644 --- a/esvg/debug.cpp +++ b/esvg/debug.cpp @@ -8,4 +8,8 @@ #include -const char * esvgLibName = "esvg "; +int32_t esvg::getLogId(void) { + static int32_t g_val = etk::log::registerInstance("esvg"); + return g_val; +} + diff --git a/esvg/debug.h b/esvg/debug.h index 0e7fdf6..3ae2399 100644 --- a/esvg/debug.h +++ b/esvg/debug.h @@ -9,20 +9,44 @@ #ifndef __ESVG_DEBUG_H__ #define __ESVG_DEBUG_H__ -#include -#include +#include -extern const char * esvgLibName; +namespace esvg { + int32_t getLogId(void); +}; +// TODO : Review this problem of multiple intanciation of "std::stringbuf sb" +#define SVG_BASE(info,data) \ + do { \ + if (info <= etk::log::getLevel(esvg::getLogId())) { \ + std::stringbuf sb; \ + std::ostream tmpStream(&sb); \ + tmpStream << data; \ + etk::log::logStream(esvg::getLogId(), info, __LINE__, __class__, __func__, tmpStream); \ + } \ + } while(0) -#define SVG_CRITICAL(data) ETK_CRITICAL(esvgLibName, data) -#define SVG_WARNING(data) ETK_WARNING(esvgLibName, data) -#define SVG_ERROR(data) ETK_ERROR(esvgLibName, data) -#define SVG_INFO(data) ETK_INFO(esvgLibName, data) -#define SVG_DEBUG(data) ETK_DEBUG(esvgLibName, data) -#define SVG_VERBOSE(data) ETK_VERBOSE(esvgLibName, data) -#define SVG_ASSERT(cond, data) ETK_ASSERT(esvgLibName, cond, data) -#define SVG_CHECK_INOUT(cond) ETK_CHECK_INOUT(esvgLibName, cond) -#define SVG_TODO(cond) ETK_TODO(esvgLibName, cond) +#define SVG_CRITICAL(data) SVG_BASE(1, data) +#define SVG_ERROR(data) SVG_BASE(2, data) +#define SVG_WARNING(data) SVG_BASE(3, data) +#ifdef DEBUG + #define SVG_INFO(data) SVG_BASE(4, data) + #define SVG_DEBUG(data) SVG_BASE(5, data) + #define SVG_VERBOSE(data) SVG_BASE(6, data) + #define SVG_TODO(data) SVG_BASE(4, "TODO : " << data) +#else + #define SVG_INFO(data) do { } while(false) + #define SVG_DEBUG(data) do { } while(false) + #define SVG_VERBOSE(data) do { } while(false) + #define SVG_TODO(data) do { } while(false) +#endif + +#define SVG_ASSERT(cond,data) \ + do { \ + if (!(cond)) { \ + SVG_CRITICAL(data); \ + assert(!#cond); \ + } \ + } while (0) #endif