[DEV] change log system

This commit is contained in:
Edouard DUPIN 2014-04-30 22:18:00 +02:00
parent 9229886513
commit 95215e438d
3 changed files with 42 additions and 14 deletions

View File

@ -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<float> listDot;

View File

@ -8,4 +8,8 @@
#include <esvg/debug.h>
const char * esvgLibName = "esvg ";
int32_t esvg::getLogId(void) {
static int32_t g_val = etk::log::registerInstance("esvg");
return g_val;
}

View File

@ -9,20 +9,44 @@
#ifndef __ESVG_DEBUG_H__
#define __ESVG_DEBUG_H__
#include <etk/types.h>
#include <etk/debugGeneric.h>
#include <etk/log.h>
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