提交 253ace53 编写于 作者: L liuruilong

update log module

上级 0e1891e5
......@@ -45,11 +45,12 @@ namespace paddle_mobile {
static std::vector<std::string> logs{"NO", "ERROR ", "WARNING",
"INFO ", "DEBUG ", "DEBUG1 ",
"DEBUG2 ", "DEBUG3 ", "DEBUG4 "};
struct ToLog;
struct Print;
struct Print {
friend struct ToLog;
template <typename T> Print &operator<<(T const &value) {
buffer_ << value;
return *this;
......@@ -100,6 +101,8 @@ namespace paddle_mobile {
.str())
#define DLOG \
if (paddle_mobile::kLOG_DEBUG > paddle_mobile::log_level) { \
} else \
paddle_mobile::ToLog( \
paddle_mobile::kLOG_DEBUG, \
(std::stringstream() \
......@@ -109,6 +112,16 @@ namespace paddle_mobile {
.str())
}
#define LOGF(level, format, ...) \
if (level > paddle_mobile::log_level) { \
} else \
printf(format, ##__VA_ARGS__)
#define DLOGF(format, ...) \
if (paddle_mobile::kLOG_DEBUG > paddle_mobile::log_level) { \
} else \
printf(format, ##__VA_ARGS__)
#else
namespace paddle_mobile {
......@@ -150,5 +163,10 @@ namespace paddle_mobile {
if (true) { \
} else \
paddle_mobile::ToLog(paddle_mobile::kLOG_DEBUG)
#define LOGF(level, format, ...)
#define DLOGF(format, ...)
}
#endif
......@@ -19,13 +19,19 @@ SOFTWARE.
#include "common/log.h"
int main() {
LOG(paddle_mobile::kLOG_DEBUG) << "test debug"
<< " next log";
DLOGF("DASJFDAFJ%d -- %f", 12345, 344.234);
LOG(paddle_mobile::kLOG_DEBUG) << "test debug" << " next log";
LOG(paddle_mobile::kLOG_DEBUG1) << "test debug1"
<< " next log";
LOG(paddle_mobile::kLOG_DEBUG2) << "test debug2"
<< " next log";
DLOG << "test DLOG";
LOG(paddle_mobile::kLOG_ERROR) << " error occur !";
return 0;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册