mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-30 02:19:35 +08:00
Added debug macros
This commit is contained in:
@@ -114,23 +114,35 @@ template <typename Sink, typename... Args>
|
||||
std::shared_ptr<spdlog::logger> create(const std::string& logger_name, const Args&...);
|
||||
|
||||
|
||||
|
||||
|
||||
// Stop logging by setting all the loggers to log level OFF
|
||||
void stop();
|
||||
|
||||
|
||||
//
|
||||
// Trace macro enabled only at debug compile
|
||||
// Example: SPDLOG_TRACE(my_logger, "Some trace message");
|
||||
// Trace & debug macros to be switched on/off at compile time for zero cost debug statements.
|
||||
// Note: using these mactors overrides the runtime log threshold of the logger.
|
||||
//
|
||||
#ifdef _DEBUG
|
||||
#define SPDLOG_TRACE(logger, ...) logger->log(__FILE__, " #", __LINE__,": " __VA_ARGS__)
|
||||
// Example:
|
||||
//
|
||||
// Enable debug macro, must be defined before including spdlog.h
|
||||
// #define SPDLOG_DEBUG_ON
|
||||
// include "spdlog/spdlog.h"
|
||||
// SPDLOG_DEBUG(my_logger, "Some debug message {} {}", 1, 3.2);
|
||||
//
|
||||
|
||||
#ifdef SPDLOG_TRACE_ON
|
||||
#define SPDLOG_TRACE(logger, ...) logger->force_log(level::TRACE, __FILE__, " #", __LINE__,": " __VA_ARGS__)
|
||||
#else
|
||||
#define SPDLOG_TRACE(logger, ...) {}
|
||||
#define SPDLOG_TRACE(logger, ...)
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef SPDLOG_DEBUG_ON
|
||||
#define SPDLOG_DEBUG(logger, ...) logger->force_log(level::DEBUG, __VA_ARGS__)
|
||||
#else
|
||||
#define SPDLOG_DEBUG(logger, ...)
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#include "details/spdlog_impl.h"
|
||||
|
Reference in New Issue
Block a user