mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-28 17:19:34 +08:00
replace constexpr with const becasuse vs2013 lack of support
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
// uses stack_buf as the underlying buffer (upto 192 bytes before using the heap)
|
||||
|
||||
#include <ostream>
|
||||
#include <iomanip>
|
||||
#include "stack_buf.h"
|
||||
|
||||
namespace c11log
|
||||
@@ -13,8 +14,8 @@ namespace details
|
||||
|
||||
class stack_devicebuf :public std::streambuf
|
||||
{
|
||||
public:
|
||||
static constexpr unsigned short stack_size = 192;
|
||||
public:
|
||||
static const unsigned short stack_size = 192;
|
||||
using stackbuf_t = stack_buf<stack_size>;
|
||||
|
||||
stack_devicebuf() = default;
|
||||
|
@@ -6,7 +6,6 @@
|
||||
#include "fast_oss.h"
|
||||
|
||||
|
||||
|
||||
// line_logger class.
|
||||
// aggregates single log line (on the stack if possibe) and calls the logger upon destruction
|
||||
|
||||
|
@@ -17,7 +17,7 @@ class stack_buf
|
||||
public:
|
||||
using bufpair_t = std::pair<const char*, std::size_t>;
|
||||
using iterator = char const*;
|
||||
static constexpr unsigned short stack_size = STACK_SIZE;
|
||||
static const unsigned short stack_size = STACK_SIZE;
|
||||
stack_buf() :_v(), _stack_size(0) {}
|
||||
~stack_buf() = default;
|
||||
|
||||
|
@@ -34,10 +34,12 @@ public:
|
||||
{
|
||||
details::fast_oss oss;
|
||||
_format_time(msg.time, oss);
|
||||
|
||||
if(!msg.logger_name.empty())
|
||||
oss << " [" << msg.logger_name << ':' << c11log::level::to_str(msg.level) << "] ";
|
||||
else
|
||||
oss << " [" << c11log::level::to_str(msg.level) << "] ";
|
||||
|
||||
oss << msg.raw << details::os::eol();
|
||||
msg.formatted = oss.str();
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ public:
|
||||
using sinks_vector_t = std::vector<sink_ptr>;
|
||||
using sinks_init_list = std::initializer_list<sink_ptr>;
|
||||
|
||||
using formatter_ptr = std::shared_ptr<c11log::formatters::formatter>;
|
||||
using formatter_ptr = std::unique_ptr<c11log::formatters::formatter>;
|
||||
|
||||
logger(const std::string& name, sinks_init_list, formatter_ptr = nullptr);
|
||||
logger(const std::string& name, sink_ptr, formatter_ptr = nullptr);
|
||||
@@ -92,18 +92,19 @@ logger& get_logger(const std::string& name);
|
||||
|
||||
inline c11log::logger::logger(const std::string& name, sinks_init_list sinks_list, formatter_ptr f) :
|
||||
_logger_name(name),
|
||||
_formatter(f),
|
||||
_formatter(std::move(f)),
|
||||
_sinks(sinks_list)
|
||||
{
|
||||
//Seems that vs2013 doesnt support std::atomic member initialization, so its done here
|
||||
_min_level = level::INFO;
|
||||
if(!_formatter)
|
||||
_formatter = std::make_shared<formatters::default_formatter>();
|
||||
_formatter = std::make_unique<formatters::default_formatter>();
|
||||
|
||||
}
|
||||
|
||||
|
||||
inline c11log::logger::logger(const std::string& name, sink_ptr sink, formatter_ptr f) :
|
||||
logger(name, {sink}, f) {}
|
||||
logger(name, {sink}, std::move(f)) {}
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user