0

I am currently implementing a library where I use spdlog for logging. In order to disable logging in Release mode the following can be implemented:

#if !defined(NDEBUG)
LOG(...) Logger::log(__VA_ARGS__)
#else
#define LOG(...) (void)0
#endif

So if LOG(...) macro is empty in Release mode should the spdlog be not linked to the library? So that application that uses my library wouldn't have to be distributed with spdlog dll. What is the correct approach?

  • 3
    The linker won't add any unused functions. Also, why would you want to completely disable logging for release builds? That sounds odd for me. – πάντα ῥεῖ Apr 07 '23 at 13:18
  • Why should it be kept if there is no console to log to? – RafalMaziejuk Apr 07 '23 at 14:11
  • Logging to file is a *very* useful feature. Most loggers can have different levels of logging, for release builds you can enable errors and warnings, while leaving info and debug logging enabled by default in your debug builds. But also leave the possibility to enable debug logging even in your release builds, as it could help find problems that are hard to replicate. – Some programmer dude Apr 07 '23 at 14:47
  • Yes, I understand the need but I'm not sure how logging should be handled when my library will be shipped with user's application (for example a game, I'm implementing graphics library). – RafalMaziejuk Apr 07 '23 at 14:53

0 Answers0