spdlog/include/spdlog/sinks/sink.h

46 lines
898 B
C
Raw Normal View History

2016-04-20 04:57:49 -04:00
//
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#pragma once
#include "../details/log_msg.h"
2016-04-20 04:57:49 -04:00
namespace spdlog
{
namespace sinks
{
class sink
{
public:
2018-02-24 17:56:56 -05:00
virtual ~sink() = default;
2016-04-20 04:57:49 -04:00
virtual void log(const details::log_msg& msg) = 0;
virtual void flush() = 0;
bool should_log(level::level_enum msg_level) const;
void set_level(level::level_enum log_level);
level::level_enum level() const;
private:
2018-02-24 18:31:14 -05:00
level_t _level{ level::trace };
2016-04-20 04:57:49 -04:00
};
2016-09-14 17:38:21 -04:00
inline bool sink::should_log(level::level_enum msg_level) const
{
return msg_level >= _level.load(std::memory_order_relaxed);
}
2016-09-14 17:38:21 -04:00
inline void sink::set_level(level::level_enum log_level)
{
_level.store(log_level);
}
2016-09-14 17:38:21 -04:00
inline level::level_enum sink::level() const
{
return static_cast<spdlog::level::level_enum>(_level.load(std::memory_order_relaxed));
}
2016-04-20 04:57:49 -04:00
}
}