abumq / easyloggingpp

C++ logging library. It is extremely powerful, extendable, light-weight, fast performing, thread and type safe and consists of many built-in features. It provides ability to write logs in your own customized format. It also provide support for logging your classes, third-party libraries, STL and third-party containers etc.
MIT License
3.75k stars 918 forks source link

easylogging++ disable DEBUG preprocessing flag #808

Open ceandrade opened 2 years ago

ceandrade commented 2 years ago

The preprocessing flag DEBUG is commonly used for many codebases. Usually, people seeking to debug use -DDEBUG in the compiler flags to activate debugging. However, if you are using easylogging++, you will have some weird behavior because easylogging++ disables (more appropriately, undefine) DEBUG (see here).

One way to circumvent this is to use the following piece at the beginning of your file:

#ifdef DEBUG
#define DEBUG_BY_PASS_EASYLOGGING
#endif

#include "third_part/easylogging++/easylogging++.h"

// Restore the DEBUG status.
#ifdef DEBUG_BY_PASS_EASYLOGGING
#define DEBUG
#endif

This works fine, but it is a little bit inconvenient because you must do it on all files that include easylogging++.

Is that a reason we need to disable the flag DEBUG? Can you do it in another way?

Thanks