Skip to content
Snippets Groups Projects
Commit b26a4888 authored by Jeremie Deray's avatar Jeremie Deray
Browse files

debug macro compile time only

parent fffcaf17
No related branches found
No related tags found
1 merge request!99Wolf logging macro
......@@ -20,15 +20,5 @@ int main(int, char*[])
WOLF_DEBUG("test debug ", 5, " ", 0.123);
// manually enable debug logging
WOLF_ENABLE_DEBUG_LOG();
WOLF_DEBUG("test enable debug");
// manually disable debug logging
WOLF_DISABLE_DEBUG_LOG();
WOLF_DEBUG("test disable debug");
return 0;
}
......@@ -51,10 +51,6 @@ public:
template<typename... Args>
void trace(const Args&... args);
void enable_debug(const bool enable);
bool enable_debug();
bool set_async_queue(const std::size_t q_size);
protected:
......@@ -92,10 +88,6 @@ Logger::Logger()
// Create main logger
console_ = spdlog::stdout_color_mt(log_name_);
#ifdef _WOLF_DEBUG
enable_debug(true);
#endif
#ifdef _WOLF_TRACE
console_->set_level(spdlog::level::trace);
#endif
......@@ -144,17 +136,6 @@ void Logger::trace(const Args&... args)
console_->trace(repeat_string("{}", sizeof...(args)).c_str(), args...);
}
inline void Logger::enable_debug(const bool enable)
{
(enable)? console_->set_level(spdlog::level::debug) :
console_->set_level(spdlog::level::info);
}
inline bool Logger::enable_debug()
{
return console_->level() == spdlog::level::debug;
}
inline bool Logger::set_async_queue(const std::size_t q_size)
{
bool p2 = q_size%2 == 0;
......@@ -176,20 +157,16 @@ inline bool Logger::set_async_queue(const std::size_t q_size)
#define WOLF_ERROR(...) \
wolf::internal::Logger::get().error(__VA_ARGS__);
#define WOLF_DEBUG(...) \
wolf::internal::Logger::get().debug(__VA_ARGS__);
#define WOLF_ENABLE_DEBUG_LOG() \
wolf::internal::Logger::get().enable_debug(true);
#define WOLF_DISABLE_DEBUG_LOG() \
wolf::internal::Logger::get().enable_debug(false);
#ifdef _WOLF_DEBUG
#define WOLF_DEBUG(...) \
wolf::internal::Logger::get().debug(__VA_ARGS__);
#else
#define WOLF_DEBUG(...)
#endif
#define WOLF_ASYNC_QUEUE_LOG(x) \
wolf::internal::Logger::get().set_async_queue(x);
// @Todo: re-assess TRACE level (info/debug/error)
// it should probably be custom while avoiding spdlog trace.
#ifdef _WOLF_TRACE
#define WOLF_TRACE(...) \
char this_file[] = __FILE__;\
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment