[DEV] change log system

This commit is contained in:
Edouard DUPIN 2014-04-30 22:18:00 +02:00
parent 4c336334a8
commit 889807e0b9
2 changed files with 40 additions and 13 deletions

View File

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

View File

@ -9,20 +9,44 @@
#ifndef __EGAMI_DEBUG_H__
#define __EGAMI_DEBUG_H__
#include <etk/types.h>
#include <etk/debugGeneric.h>
#include <etk/log.h>
extern const char * egamiLibName;
namespace egami {
int32_t getLogId(void);
};
// TODO : Review this problem of multiple intanciation of "std::stringbuf sb"
#define EGAMI_BASE(info,data) \
do { \
if (info <= etk::log::getLevel(egami::getLogId())) { \
std::stringbuf sb; \
std::ostream tmpStream(&sb); \
tmpStream << data; \
etk::log::logStream(egami::getLogId(), info, __LINE__, __class__, __func__, tmpStream); \
} \
} while(0)
#define EGAMI_CRITICAL(data) ETK_CRITICAL(egamiLibName, data)
#define EGAMI_WARNING(data) ETK_WARNING(egamiLibName, data)
#define EGAMI_ERROR(data) ETK_ERROR(egamiLibName, data)
#define EGAMI_INFO(data) ETK_INFO(egamiLibName, data)
#define EGAMI_DEBUG(data) ETK_DEBUG(egamiLibName, data)
#define EGAMI_VERBOSE(data) ETK_VERBOSE(egamiLibName, data)
#define EGAMI_ASSERT(cond,data) ETK_ASSERT(egamiLibName, cond, data)
#define EGAMI_CHECK_INOUT(cond) ETK_CHECK_INOUT(egamiLibName, cond)
#define EGAMI_TODO(cond) ETK_TODO(egamiLibName, cond)
#define EGAMI_CRITICAL(data) EGAMI_BASE(1, data)
#define EGAMI_ERROR(data) EGAMI_BASE(2, data)
#define EGAMI_WARNING(data) EGAMI_BASE(3, data)
#ifdef DEBUG
#define EGAMI_INFO(data) EGAMI_BASE(4, data)
#define EGAMI_DEBUG(data) EGAMI_BASE(5, data)
#define EGAMI_VERBOSE(data) EGAMI_BASE(6, data)
#define EGAMI_TODO(data) EGAMI_BASE(4, "TODO : " << data)
#else
#define EGAMI_INFO(data) do { } while(false)
#define EGAMI_DEBUG(data) do { } while(false)
#define EGAMI_VERBOSE(data) do { } while(false)
#define EGAMI_TODO(data) do { } while(false)
#endif
#define EGAMI_ASSERT(cond,data) \
do { \
if (!(cond)) { \
EGAMI_CRITICAL(data); \
assert(!#cond); \
} \
} while (0)
#endif