Closed xinthose closed 2 years ago
I figured out the issue. I had to change all of my logging macros to a different name (DEBUG1
, INFO1
, WARNING1
, ERROR1
, FATAL1
). Does pistache use these names in its logging then? (DEBUG
, INFO
, WARNING
, ERROR
, FATAL
). To avoid future issues, you should probably use unique names likeP_INFO
in the library.
Does pistache use these names in its logging then?
No, Pistache does not define those macros. It only defines TRACE
, DEBUG
, etc in an enum class named Level
, in namespace Pistache::Log
. Are you sure that Pistache is the one causing your issue?
A trick that you can do is add -DDEBUG=@@@
to your compiler args. This will cause the first (re)definition of DEBUG to fail, and make it easier to find.
@Tachi107 yes, because my code compiles fine without it.
@dennisjenkins75 I just tried compiling with that flag and got that DEBUG
is redefined in my header file
src/../include/logging.hpp:17: warning: "DEBUG" redefined
17 | #define DEBUG BOOST_LOG_SEV(my_logger::get(), boost::log::trivial::debug) << __FILENAME__ << "/" << __FUNCTION__ << ":" << __LINE__ << " >> "
@Tachi107 yes, because my code compiles fine without it.
Does your code compile with Pistache and without the Boost library?
@Tachi107 I cannot test that because boost and global logging is an integral part of my program. I am fine with using a different macro name, just glad I found the issue.
It's hard (for me) to figure out what issue are you encountering... Could you provide a minimal example that is reproducible for us?
@Tachi107 the issue is that my DEBUG
define is conflicting with yours https://github.com/pistacheio/pistache/blob/615281a33eccd9c1d09f274254fd28313b0cd582/include/pistache/string_logger.h#L24
Oh, now I got it... Pistache is not creating issues in your code, it's your code that is creating issues in Pistache :)
Pistache defines the identifier DEBUG
in an enum class, inside a nested namespace. This means that Pistache's DEBUG
won't ever pollute user's global namespace (unless you do something like using Pistache::Log::Level::DEBUG
).
Now, when you define DEBUG
as a macro in your code, the word DEBUG
in Pistache's headers get replaced with the expanded macro, and that's obviously going to cause issues.
This isn't really a bug in Pistache IMO, it's a bit like doing #define log my_special_function()
and expecting that everything will keep working fine.
Closing this, but if you think that I came to the wrong conclusion please let me know :)
@Tachi107 yah, thanks. At least this is documented here now in case anyone ever searches for it.
I get errors when compiling pistache with my global boost logger. My OS is Ubuntu 22. I never used to have these issues on Ubuntu 20. I am using the latest version of pistache. I am not sure how to fix this.
logging.hpp