emilk / loguru

A lightweight C++ logging library
The Unlicense
1.79k stars 260 forks source link

is that possible to ads some alias for some logging level #121

Closed qingfengxia closed 5 years ago

qingfengxia commented 5 years ago

I usually use LOG_F(), but if I want to print some "PROGRESS" or "DEBUG" information, I would use LOG_F(1, ...), but it is not elegant. Because it is a macro function, I can not use #define PROGRESS 1 to avoid the log level as integer. Since C++ does not stop enum name pointing to existing value. Can you add some alias to

Verbosity_1 = 1 Verbosity_PROGRESS = 1 Verbosity_VERBOSITY2 = 2

I am not sure if Verbosity_DEBUG = 5 will cause some trouble as DEBUG may be a common user-defined macro.

loguru is really nice library! Thank you!

emilk commented 5 years ago

LOG_* always uses named verbosity levels, but you can use VLOG_* to pass an integer verbosity instead:

#define PROGRESS 1
VLOG_F(PROGRESS, "Working hard");
qingfengxia commented 5 years ago

great!, you can close this issue now, sorry, I am not familiar with all API.

emilk commented 5 years ago

No problem - you can read more here: https://emilk.github.io/loguru/index.html#logging/logfunctions/vlog_f(verbosity,fmt,...)