Commit 1f3dea60 authored by gabime's avatar gabime

try to prevent optimizer to remove null sink code altogether

parent a7c06ead
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "spdlog/details/synchronous_factory.h" #include "spdlog/details/synchronous_factory.h"
#include <mutex> #include <mutex>
#include <stdio.h>
namespace spdlog { namespace spdlog {
namespace sinks { namespace sinks {
...@@ -16,7 +17,16 @@ template<typename Mutex> ...@@ -16,7 +17,16 @@ template<typename Mutex>
class null_sink : public base_sink<Mutex> class null_sink : public base_sink<Mutex>
{ {
protected: protected:
void sink_it_(const details::log_msg &) override {} void sink_it_(const details::log_msg &msg) override
{
// prevent optimizer to remove this sink altogether (and do useful check while at it).
if(msg.level == level::off)
{
printf("Should never not be called if level is off!\n");
}
assert(msg.level != level::off);
}
void flush_() override {} void flush_() override {}
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment