audio-river/river/debug.h

52 lines
1.4 KiB
C
Raw Normal View History

2015-01-25 22:17:06 +01:00
/** @file
* @author Edouard DUPIN
* @copyright 2015, Edouard DUPIN, all right reserved
* @license APACHE v2.0 (see license file)
*/
#ifndef __RIVER_DEBUG_H__
#define __RIVER_DEBUG_H__
2015-01-25 22:17:06 +01:00
#include <etk/log.h>
2015-02-05 19:10:53 +01:00
namespace river {
2015-01-25 22:17:06 +01:00
int32_t getLogId();
};
// TODO : Review this problem of multiple intanciation of "std::stringbuf sb"
#define RIVER_BASE(info,data) \
2015-01-25 22:17:06 +01:00
do { \
2015-02-05 19:10:53 +01:00
if (info <= etk::log::getLevel(river::getLogId())) { \
2015-01-25 22:17:06 +01:00
std::stringbuf sb; \
std::ostream tmpStream(&sb); \
tmpStream << data; \
2015-02-05 19:10:53 +01:00
etk::log::logStream(river::getLogId(), info, __LINE__, __class__, __func__, tmpStream); \
2015-01-25 22:17:06 +01:00
} \
} while(0)
#define RIVER_CRITICAL(data) RIVER_BASE(1, data)
#define RIVER_ERROR(data) RIVER_BASE(2, data)
#define RIVER_WARNING(data) RIVER_BASE(3, data)
2015-01-25 22:17:06 +01:00
#ifdef DEBUG
#define RIVER_INFO(data) RIVER_BASE(4, data)
#define RIVER_DEBUG(data) RIVER_BASE(5, data)
#define RIVER_VERBOSE(data) RIVER_BASE(6, data)
#define RIVER_TODO(data) RIVER_BASE(4, "TODO : " << data)
2015-01-25 22:17:06 +01:00
#else
#define RIVER_INFO(data) do { } while(false)
#define RIVER_DEBUG(data) do { } while(false)
#define RIVER_VERBOSE(data) do { } while(false)
#define RIVER_TODO(data) do { } while(false)
2015-01-25 22:17:06 +01:00
#endif
#define RIVER_ASSERT(cond,data) \
2015-01-25 22:17:06 +01:00
do { \
if (!(cond)) { \
RIVER_CRITICAL(data); \
2015-01-25 22:17:06 +01:00
assert(!#cond); \
} \
} while (0)
#endif