mirror of
https://github.com/gabime/spdlog.git
synced 2025-01-12 00:40:26 +08:00
Added support for SPDLOG_NO_ATOMIC_LEVELS in tweakme.h
This commit is contained in:
parent
d0120b48c5
commit
974379c9be
@ -5,17 +5,20 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <atomic>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
|
||||||
#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
|
#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
|
||||||
#include <codecvt>
|
#include <codecvt>
|
||||||
#include <locale>
|
#include <locale>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <spdlog/details/null_mutex.h>
|
||||||
|
|
||||||
//visual studio does not support noexcept yet
|
//visual studio does not support noexcept yet
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
#define SPDLOG_NOEXCEPT noexcept
|
#define SPDLOG_NOEXCEPT noexcept
|
||||||
@ -23,7 +26,6 @@
|
|||||||
#define SPDLOG_NOEXCEPT throw()
|
#define SPDLOG_NOEXCEPT throw()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace spdlog
|
namespace spdlog
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -39,7 +41,11 @@ using log_clock = std::chrono::system_clock;
|
|||||||
using sink_ptr = std::shared_ptr < sinks::sink >;
|
using sink_ptr = std::shared_ptr < sinks::sink >;
|
||||||
using sinks_init_list = std::initializer_list < sink_ptr >;
|
using sinks_init_list = std::initializer_list < sink_ptr >;
|
||||||
using formatter_ptr = std::shared_ptr<spdlog::formatter>;
|
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
|
//Log level enum
|
||||||
namespace level
|
namespace level
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
#include <spdlog/logger.h>
|
#include <spdlog/logger.h>
|
||||||
|
|
||||||
#include <atomic>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
@ -5,7 +5,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// null, no cost mutex
|
#include <atomic>
|
||||||
|
// null, no cost dummy "mutex" and dummy "atomic" int
|
||||||
|
|
||||||
namespace spdlog
|
namespace spdlog
|
||||||
{
|
{
|
||||||
@ -20,5 +21,25 @@ struct null_mutex
|
|||||||
return true;
|
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 <vector>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <atomic>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace spdlog
|
namespace spdlog
|
||||||
@ -103,9 +102,8 @@ protected:
|
|||||||
friend details::line_logger;
|
friend details::line_logger;
|
||||||
std::string _name;
|
std::string _name;
|
||||||
std::vector<sink_ptr> _sinks;
|
std::vector<sink_ptr> _sinks;
|
||||||
formatter_ptr _formatter;
|
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.
|
// Uncomment to enable usage of wchar_t for file names on Windows.
|
||||||
// #define SPDLOG_WCHAR_FILENAMES
|
// #define SPDLOG_WCHAR_FILENAMES
|
||||||
|
1
tests/logs/.gitignore
vendored
1
tests/logs/.gitignore
vendored
@ -1 +0,0 @@
|
|||||||
*.txt
|
|
Loading…
Reference in New Issue
Block a user