Commit 974379c9 authored by gabime's avatar gabime

Added support for SPDLOG_NO_ATOMIC_LEVELS in tweakme.h

parent d0120b48
......@@ -5,17 +5,20 @@
#pragma once
#include <string>
#include <initializer_list>
#include <chrono>
#include <memory>
#include <atomic>
#include <exception>
#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
#include <codecvt>
#include <locale>
#endif
#include <spdlog/details/null_mutex.h>
//visual studio does not support noexcept yet
#ifndef _MSC_VER
#define SPDLOG_NOEXCEPT noexcept
......@@ -23,7 +26,6 @@
#define SPDLOG_NOEXCEPT throw()
#endif
namespace spdlog
{
......@@ -39,7 +41,11 @@ using log_clock = std::chrono::system_clock;
using sink_ptr = std::shared_ptr < sinks::sink >;
using sinks_init_list = std::initializer_list < sink_ptr >;
using formatter_ptr = std::shared_ptr<spdlog::formatter>;
#if defined(SPDLOG_NO_ATOMIC_LEVELS)
using atomic_level = details::null_atomic_int;
#else
using atomic_level = std::atomic_int;
#endif
//Log level enum
namespace level
......
......@@ -7,7 +7,6 @@
#include <spdlog/logger.h>
#include <atomic>
#include <memory>
#include <string>
......
......@@ -5,7 +5,8 @@
#pragma once
// null, no cost mutex
#include <atomic>
// null, no cost dummy "mutex" and dummy "atomic" int
namespace spdlog
{
......@@ -20,5 +21,25 @@ struct null_mutex
return true;
}
};
struct null_atomic_int
{
int value;
null_atomic_int() = default;
null_atomic_int(int val):value(val)
{}
int load(std::memory_order) const
{
return value;
}
void store(int val)
{
value = val;
}
};
}
}
......@@ -18,7 +18,6 @@
#include <vector>
#include <memory>
#include <atomic>
#include <string>
namespace spdlog
......@@ -104,8 +103,7 @@ protected:
std::string _name;
std::vector<sink_ptr> _sinks;
formatter_ptr _formatter;
std::atomic_int _level;
spdlog::atomic_level _level;
};
}
......
......@@ -53,6 +53,12 @@
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment to avoid spdlog's usage of atomic log levels
// Use only if your code never modifies a logger's log levels concurrently.
// #define SPDLOG_NO_ATOMIC_LEVELS
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment to enable usage of wchar_t for file names on Windows.
// #define SPDLOG_WCHAR_FILENAMES
......
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