로딩중...
검색중...
일치하는것 없음
macro.hpp 파일 참조

이 파일의 소스 코드 페이지로 가기

매크로

#define BY_E(fmt, ...)   ::by::richLog(::by::errLv::ERR, __FILENAME__, __func__, __LINE__, fmt "\n", ##__VA_ARGS__)
 Log macro: prints debug log on console and file.
 
#define BY_W(fmt, ...)   ::by::richLog(::by::errLv::WARN, __FILENAME__, __func__, __LINE__, fmt "\n", ##__VA_ARGS__)
 
#define BY_I(fmt, ...)   ::by::richLog(::by::errLv::INFO, __FILENAME__, __func__, __LINE__, fmt "\n", ##__VA_ARGS__)
 
#define BY_E_SCOPE(fmt, ...)
 Logs scope entry and exit with execution time and depth visualization.
 
#define BY_W_SCOPE(fmt, ...)
 
#define BY_I_SCOPE(fmt, ...)
 
#define BY_DE(fmt, ...)   void()
 
#define BY_DW(fmt, ...)   void()
 
#define BY_DI(fmt, ...)   void()
 
#define BY_DE_SCOPE(fmt, ...)   void()
 
#define BY_DW_SCOPE(fmt, ...)   void()
 
#define BY_DI_SCOPE(fmt, ...)   void()
 
#define BY_SIDE_FUNC_3(paramPtr, expr, ret)    { return paramPtr ? expr : ret; }
 

상세한 설명

Log macro definitions for byeol language logging system

매크로 문서화

◆ BY_E

#define BY_E ( fmt,
... )   ::by::richLog(::by::errLv::ERR, __FILENAME__, __func__, __LINE__, fmt "\n", ##__VA_ARGS__)

Log macro: prints debug log on console and file.

You can check the file recorded logs at your current work directory named to "logs".

If you dbg version macros, _DI, _DE, _DW, then log msg will be left only if you use dbg configuration.

BY_I("just message.")
BY_I("with format=%x string=%s", &format, format.c_str())

◆ BY_E_SCOPE

#define BY_E_SCOPE ( fmt,
... )
값:
BY_E("▶ " fmt, ##__VA_ARGS__); \
BY_END(scopeLog, [&](nllong elapsed) { BY_E("◀ " fmt, ##__VA_ARGS__); });
static void incLv()
Increases the current depth level.
Definition line.cpp:33
#define BY_E(fmt,...)
Log macro: prints debug log on console and file.
Definition macro.hpp:22

Logs scope entry and exit with execution time and depth visualization.

Uses BY_END and scopeLog for RAII-based scope logging. Graph depth is automatically incremented on entry and decremented on exit.

경고
Arguments are evaluated twice. Avoid side-effect expressions.
void good(int id) {
BY_E_SCOPE("good id=%d", id); // OK
// ... work ...
BY_I("hello log!")
}
Outputs:
E <good#130> ▶ good id=123
I <good#131> ┣ hello log!
E <good#130> ◀ good id=123
void bad() {
BY_E_SCOPE("count=%d", counter++); // WRONG: counter increments twice!
}
#define BY_E_SCOPE(fmt,...)
Logs scope entry and exit with execution time and depth visualization.
Definition macro.hpp:72

careful when you use BY_?_SCOPE macro in 'if' block statement

as you can see below, it defines 'end' instance to catch when the scope ends. so if you use BY_E_SCOPE inside of block statement by expecting it works when the func ends, it won't work as you expected.

void foo() {
if(isVerbose) BY_I_SCOPE("okay, verbose mode is on.");
BY_I("hello");
}

in above example, macro will expand like below,

void foo() {
if(isVerbose)
BY_E("▶ okay, verbose mode is on.");
BY_END(scopeLog, ...., "◀ okay, verbose mode is on.")
BY_I("hello");
}

so the start and end of scope logs always printed.

◆ BY_I_SCOPE

#define BY_I_SCOPE ( fmt,
... )
값:
BY_I("▶ " fmt, ##__VA_ARGS__); \
::by::line::incLv(); \
BY_END(scopeLog, [&](nllong elapsed) { BY_I("◀ " fmt, ##__VA_ARGS__); });

◆ BY_W_SCOPE

#define BY_W_SCOPE ( fmt,
... )
값:
BY_W("▶ " fmt, ##__VA_ARGS__); \
BY_END(scopeLog, [&](nllong elapsed) { BY_W("◀ " fmt, ##__VA_ARGS__); });