[DEV] update Log interafce

This commit is contained in:
Edouard DUPIN 2015-03-25 21:14:12 +01:00
parent 13043536c2
commit 6622cd8237
3 changed files with 8 additions and 83 deletions

View File

@ -13,16 +13,7 @@
namespace river {
int32_t getLogId();
};
// TODO : Review this problem of multiple intanciation of "std::stringbuf sb"
#define RIVER_BASE(info,data) \
do { \
if (info <= etk::log::getLevel(river::getLogId())) { \
std::stringbuf sb; \
std::ostream tmpStream(&sb); \
tmpStream << data; \
etk::log::logStream(river::getLogId(), info, __LINE__, __class__, __func__, tmpStream); \
} \
} while(0)
#define RIVER_BASE(info,data) TK_LOG_BASE(river::getLogId(),info,data)
#define RIVER_CRITICAL(data) RIVER_BASE(1, data)
#define RIVER_ERROR(data) RIVER_BASE(2, data)

View File

@ -14,16 +14,7 @@
namespace appl {
int32_t getLogId();
};
// TODO : Review this problem of multiple intanciation of "std::stringbuf sb"
#define APPL_BASE(info,data) \
do { \
if (info <= etk::log::getLevel(appl::getLogId())) { \
std::stringbuf sb; \
std::ostream tmpStream(&sb); \
tmpStream << data; \
etk::log::logStream(appl::getLogId(), info, __LINE__, __class__, __func__, tmpStream); \
} \
} while(0)
#define APPL_BASE(info,data) TK_LOG_BASE(appl::getLogId(),info,data)
#define APPL_CRITICAL(data) APPL_BASE(1, data)
#define APPL_ERROR(data) APPL_BASE(2, data)

View File

@ -28,77 +28,20 @@
#undef __class__
#define __class__ "test"
/*
static void threadVolume() {
std11::shared_ptr<river::Manager> manager;
manager = river::Manager::create("testApplication");
std11::shared_ptr<testCallbackVolume> process = std11::make_shared<testCallbackVolume>(manager);
usleep(100000);
process->run();
process.reset();
usleep(500000);
}
TEST(TestALL, testInputCallBackMicClean) {
std11::shared_ptr<river::Manager> manager;
manager = river::Manager::create("testApplication");
std11::thread tmpThread(std11::bind(&threadVolume));
usleep(30000);
APPL_INFO("test input (callback mode)");
std11::shared_ptr<testInCallback> process = std11::make_shared<testInCallback>(manager, "microphone-clean");
process->run();
usleep(100000);
process.reset();
usleep(500000);
tmpThread.join();
}
*/
int main(int argc, char **argv) {
// init Google test :
::testing::InitGoogleTest(&argc, const_cast<char **>(argv));
// the only one init for etk:
etk::log::setLevel(etk::log::logLevelNone);
for (int32_t iii=0; iii<argc ; ++iii) {
std::string data = argv[iii];
if (data == "-l0") {
etk::log::setLevel(etk::log::logLevelNone);
} else if (data == "-l1") {
etk::log::setLevel(etk::log::logLevelCritical);
} else if (data == "-l2") {
etk::log::setLevel(etk::log::logLevelError);
} else if (data == "-l3") {
etk::log::setLevel(etk::log::logLevelWarning);
} else if (data == "-l4") {
etk::log::setLevel(etk::log::logLevelInfo);
} else if (data == "-l5") {
etk::log::setLevel(etk::log::logLevelDebug);
} else if (data == "-l6") {
etk::log::setLevel(etk::log::logLevelVerbose);
} else if ( data == "-h"
|| data == "--help") {
etk::init(_argc, _argv);
for (int32_t iii=0; iii<_argc ; ++iii) {
std::string data = _argv[iii];
if ( data == "-h"
|| data == "--help") {
APPL_INFO("Help : ");
APPL_INFO(" ./xxx [options]");
APPL_INFO(" -l0: debug None");
APPL_INFO(" -l1: debug Critical");
APPL_INFO(" -l2: debug Error");
APPL_INFO(" -l3: debug Warning");
APPL_INFO(" -l4: debug Info");
APPL_INFO(" -l5: debug Debug");
APPL_INFO(" -l6: debug Verbose");
APPL_INFO(" -h/--help: this help");
APPL_INFO(" ./xxx ---");
exit(0);
}
}
etk::setArgZero(argv[0]);
etk::initDefaultFolder("exml_test");
return RUN_ALL_TESTS();
}