Update dependency to spdlog 0.16.3
This commit is contained in:
parent
2b88a0d051
commit
a691fd03dc
2
vendor/README
vendored
2
vendor/README
vendored
@ -3,4 +3,4 @@ scrypt: http://www.tarsnap.com/scrypt.html
|
||||
- changed: commented out compiler warnings about a workaround for a llvm bug
|
||||
googletest: https://github.com/google/googletest/tree/release-1.8.0
|
||||
- changed: added NOLINT comment as workaround for clang-tidy warning https://github.com/google/googletest/issues/853
|
||||
spdlog: https://github.com/gabime/spdlog/tree/v0.14.0/include/spdlog
|
||||
spdlog: https://github.com/gabime/spdlog/tree/v0.16.3/include/spdlog
|
||||
|
6
vendor/spdlog/spdlog/async_logger.h
vendored
6
vendor/spdlog/spdlog/async_logger.h
vendored
@ -15,8 +15,8 @@
|
||||
// 3. will throw spdlog_ex upon log exceptions
|
||||
// Upon destruction, logs all remaining messages in the queue before destructing..
|
||||
|
||||
#include "spdlog/common.h"
|
||||
#include "spdlog/logger.h"
|
||||
#include "common.h"
|
||||
#include "logger.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
@ -79,4 +79,4 @@ private:
|
||||
}
|
||||
|
||||
|
||||
#include "spdlog/details/async_logger_impl.h"
|
||||
#include "details/async_logger_impl.h"
|
||||
|
15
vendor/spdlog/spdlog/common.h
vendored
15
vendor/spdlog/spdlog/common.h
vendored
@ -18,7 +18,7 @@
|
||||
#include <locale>
|
||||
#endif
|
||||
|
||||
#include "spdlog/details/null_mutex.h"
|
||||
#include "details/null_mutex.h"
|
||||
|
||||
//visual studio upto 2013 does not support noexcept nor constexpr
|
||||
#if defined(_MSC_VER) && (_MSC_VER < 1900)
|
||||
@ -29,9 +29,11 @@
|
||||
#define SPDLOG_CONSTEXPR constexpr
|
||||
#endif
|
||||
|
||||
// See tweakme.h
|
||||
#if !defined(SPDLOG_FINAL)
|
||||
// final keyword support. On by default. See tweakme.h
|
||||
#if defined(SPDLOG_NO_FINAL)
|
||||
#define SPDLOG_FINAL
|
||||
#else
|
||||
#define SPDLOG_FINAL final
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
@ -42,8 +44,7 @@
|
||||
#define SPDLOG_DEPRECATED
|
||||
#endif
|
||||
|
||||
|
||||
#include "spdlog/fmt/fmt.h"
|
||||
#include "fmt/fmt.h"
|
||||
|
||||
namespace spdlog
|
||||
{
|
||||
@ -82,9 +83,9 @@ typedef enum
|
||||
} level_enum;
|
||||
|
||||
#if !defined(SPDLOG_LEVEL_NAMES)
|
||||
#define SPDLOG_LEVEL_NAMES { "trace", "debug", "info", "warning", "error", "critical", "off" };
|
||||
#define SPDLOG_LEVEL_NAMES { "trace", "debug", "info", "warning", "error", "critical", "off" }
|
||||
#endif
|
||||
static const char* level_names[] SPDLOG_LEVEL_NAMES
|
||||
static const char* level_names[] SPDLOG_LEVEL_NAMES;
|
||||
|
||||
static const char* short_level_names[] { "T", "D", "I", "W", "E", "C", "O" };
|
||||
|
||||
|
27
vendor/spdlog/spdlog/details/async_log_helper.h
vendored
27
vendor/spdlog/spdlog/details/async_log_helper.h
vendored
@ -12,12 +12,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "spdlog/common.h"
|
||||
#include "spdlog/sinks/sink.h"
|
||||
#include "spdlog/details/mpmc_bounded_q.h"
|
||||
#include "spdlog/details/log_msg.h"
|
||||
#include "spdlog/details/os.h"
|
||||
#include "spdlog/formatter.h"
|
||||
#include "../common.h"
|
||||
#include "../sinks/sink.h"
|
||||
#include "../details/mpmc_bounded_q.h"
|
||||
#include "../details/log_msg.h"
|
||||
#include "../details/os.h"
|
||||
#include "../formatter.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <exception>
|
||||
@ -261,7 +261,7 @@ inline void spdlog::details::async_log_helper::flush(bool wait_for_q)
|
||||
{
|
||||
push_msg(async_msg(async_msg_type::flush));
|
||||
if (wait_for_q)
|
||||
wait_empty_q(); //return only make after the above flush message was processed
|
||||
wait_empty_q(); //return when queue is empty
|
||||
}
|
||||
|
||||
inline void spdlog::details::async_log_helper::worker_loop()
|
||||
@ -280,9 +280,9 @@ inline void spdlog::details::async_log_helper::worker_loop()
|
||||
{
|
||||
_err_handler(ex.what());
|
||||
}
|
||||
catch (...)
|
||||
catch(...)
|
||||
{
|
||||
_err_handler("Unknown exception");
|
||||
_err_handler("Unknown exeption in async logger worker loop.");
|
||||
}
|
||||
}
|
||||
if (_worker_teardown_cb) _worker_teardown_cb();
|
||||
@ -358,7 +358,6 @@ inline void spdlog::details::async_log_helper::set_formatter(formatter_ptr msg_f
|
||||
// spin, yield or sleep. use the time passed since last message as a hint
|
||||
inline void spdlog::details::async_log_helper::sleep_or_yield(const spdlog::log_clock::time_point& now, const spdlog::log_clock::time_point& last_op_time)
|
||||
{
|
||||
using namespace std::this_thread;
|
||||
using std::chrono::milliseconds;
|
||||
using std::chrono::microseconds;
|
||||
|
||||
@ -374,17 +373,17 @@ inline void spdlog::details::async_log_helper::sleep_or_yield(const spdlog::log_
|
||||
|
||||
// sleep for 20 ms upto 200 ms
|
||||
if (time_since_op <= milliseconds(200))
|
||||
return sleep_for(milliseconds(20));
|
||||
return details::os::sleep_for_millis(20);
|
||||
|
||||
// sleep for 200 ms
|
||||
return sleep_for(milliseconds(200));
|
||||
// sleep for 500 ms
|
||||
return details::os::sleep_for_millis(500);
|
||||
}
|
||||
|
||||
// wait for the queue to be empty
|
||||
inline void spdlog::details::async_log_helper::wait_empty_q()
|
||||
{
|
||||
auto last_op = details::os::now();
|
||||
while (_q.approx_size() > 0)
|
||||
while (!_q.is_empty())
|
||||
{
|
||||
sleep_or_yield(details::os::now(), last_op);
|
||||
}
|
||||
|
12
vendor/spdlog/spdlog/details/async_logger_impl.h
vendored
12
vendor/spdlog/spdlog/details/async_logger_impl.h
vendored
@ -8,8 +8,8 @@
|
||||
// Async Logger implementation
|
||||
// Use an async_sink (queue per logger) to perform the logging in a worker thread
|
||||
|
||||
#include "spdlog/details/async_log_helper.h"
|
||||
#include "spdlog/async_logger.h"
|
||||
#include "../details/async_log_helper.h"
|
||||
#include "../async_logger.h"
|
||||
|
||||
#include <string>
|
||||
#include <functional>
|
||||
@ -88,7 +88,7 @@ inline void spdlog::async_logger::_sink_it(details::log_msg& msg)
|
||||
try
|
||||
{
|
||||
#if defined(SPDLOG_ENABLE_MESSAGE_COUNTER)
|
||||
msg.msg_id = _msg_counter.fetch_add(1, std::memory_order_relaxed);
|
||||
_incr_msg_counter(msg);
|
||||
#endif
|
||||
_async_log_helper->log(msg);
|
||||
if (_should_flush_on(msg))
|
||||
@ -98,8 +98,10 @@ inline void spdlog::async_logger::_sink_it(details::log_msg& msg)
|
||||
{
|
||||
_err_handler(ex.what());
|
||||
}
|
||||
catch (...)
|
||||
catch(...)
|
||||
{
|
||||
_err_handler("Unknown exception");
|
||||
_err_handler("Unknown exception in logger " + _name);
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
44
vendor/spdlog/spdlog/details/file_helper.h
vendored
44
vendor/spdlog/spdlog/details/file_helper.h
vendored
@ -9,13 +9,14 @@
|
||||
// When failing to open a file, retry several times(5) with small delay between the tries(10 ms)
|
||||
// Throw spdlog_ex exception on errors
|
||||
|
||||
#include "spdlog/details/os.h"
|
||||
#include "spdlog/details/log_msg.h"
|
||||
#include "../details/os.h"
|
||||
#include "../details/log_msg.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <tuple>
|
||||
#include <cerrno>
|
||||
|
||||
namespace spdlog
|
||||
@ -54,7 +55,7 @@ public:
|
||||
if (!os::fopen_s(&_fd, fname, mode))
|
||||
return;
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(open_interval));
|
||||
details::os::sleep_for_millis(open_interval);
|
||||
}
|
||||
|
||||
throw spdlog_ex("Failed opening file " + os::filename_to_str(_filename) + " for writing", errno);
|
||||
@ -84,14 +85,13 @@ public:
|
||||
|
||||
void write(const log_msg& msg)
|
||||
{
|
||||
|
||||
size_t msg_size = msg.formatted.size();
|
||||
auto data = msg.formatted.data();
|
||||
if (std::fwrite(data, 1, msg_size, _fd) != msg_size)
|
||||
throw spdlog_ex("Failed writing to file " + os::filename_to_str(_filename), errno);
|
||||
}
|
||||
|
||||
size_t size()
|
||||
size_t size() const
|
||||
{
|
||||
if (!_fd)
|
||||
throw spdlog_ex("Cannot use size() on closed file " + os::filename_to_str(_filename));
|
||||
@ -103,12 +103,40 @@ public:
|
||||
return _filename;
|
||||
}
|
||||
|
||||
static bool file_exists(const filename_t& name)
|
||||
static bool file_exists(const filename_t& fname)
|
||||
{
|
||||
|
||||
return os::file_exists(name);
|
||||
return os::file_exists(fname);
|
||||
}
|
||||
|
||||
//
|
||||
// return file path and its extension:
|
||||
//
|
||||
// "mylog.txt" => ("mylog", ".txt")
|
||||
// "mylog" => ("mylog", "")
|
||||
// "mylog." => ("mylog.", "")
|
||||
// "/dir1/dir2/mylog.txt" => ("/dir1/dir2/mylog", ".txt")
|
||||
//
|
||||
// the starting dot in filenames is ignored (hidden files):
|
||||
//
|
||||
// ".mylog" => (".mylog". "")
|
||||
// "my_folder/.mylog" => ("my_folder/.mylog", "")
|
||||
// "my_folder/.mylog.txt" => ("my_folder/.mylog", ".txt")
|
||||
static std::tuple<filename_t, filename_t> split_by_extenstion(const spdlog::filename_t& fname)
|
||||
{
|
||||
auto ext_index = fname.rfind('.');
|
||||
|
||||
// no valid extension found - return whole path and empty string as extension
|
||||
if (ext_index == filename_t::npos || ext_index == 0 || ext_index == fname.size() - 1)
|
||||
return std::make_tuple(fname, spdlog::filename_t());
|
||||
|
||||
// treat casese like "/etc/rc.d/somelogfile or "/abc/.hiddenfile"
|
||||
auto folder_index = fname.rfind(details::os::folder_sep);
|
||||
if (folder_index != fname.npos && folder_index >= ext_index - 1)
|
||||
return std::make_tuple(fname, spdlog::filename_t());
|
||||
|
||||
// finally - return a valid base and extension tuple
|
||||
return std::make_tuple(fname.substr(0, ext_index), fname.substr(ext_index));
|
||||
}
|
||||
private:
|
||||
FILE* _fd;
|
||||
filename_t _filename;
|
||||
|
4
vendor/spdlog/spdlog/details/log_msg.h
vendored
4
vendor/spdlog/spdlog/details/log_msg.h
vendored
@ -5,8 +5,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "spdlog/common.h"
|
||||
#include "spdlog/details/os.h"
|
||||
#include "../common.h"
|
||||
#include "../details/os.h"
|
||||
|
||||
|
||||
#include <string>
|
||||
|
234
vendor/spdlog/spdlog/details/logger_impl.h
vendored
234
vendor/spdlog/spdlog/details/logger_impl.h
vendored
@ -5,13 +5,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "spdlog/logger.h"
|
||||
#include "spdlog/sinks/stdout_sinks.h"
|
||||
#include "../logger.h"
|
||||
#include "../sinks/stdout_sinks.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
|
||||
// create logger with given name, sinks and the default pattern formatter
|
||||
// all other ctors will call this one
|
||||
template<class It>
|
||||
@ -58,7 +57,6 @@ inline void spdlog::logger::set_pattern(const std::string& pattern, pattern_time
|
||||
_set_pattern(pattern, pattern_time);
|
||||
}
|
||||
|
||||
|
||||
template <typename... Args>
|
||||
inline void spdlog::logger::log(level::level_enum lvl, const char* fmt, const Args&... args)
|
||||
{
|
||||
@ -67,16 +65,22 @@ inline void spdlog::logger::log(level::level_enum lvl, const char* fmt, const Ar
|
||||
try
|
||||
{
|
||||
details::log_msg log_msg(&_name, lvl);
|
||||
|
||||
#if defined(SPDLOG_FMT_PRINTF)
|
||||
fmt::printf(log_msg.raw, fmt, args...);
|
||||
#else
|
||||
log_msg.raw.write(fmt, args...);
|
||||
#endif
|
||||
_sink_it(log_msg);
|
||||
}
|
||||
catch (const std::exception &ex)
|
||||
{
|
||||
_err_handler(ex.what());
|
||||
}
|
||||
catch (...)
|
||||
catch(...)
|
||||
{
|
||||
_err_handler("Unknown exception");
|
||||
_err_handler("Unknown exception in logger " + _name);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,9 +100,9 @@ inline void spdlog::logger::log(level::level_enum lvl, const char* msg)
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
_err_handler("Unknown exception");
|
||||
_err_handler("Unknown exception in logger " + _name);
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@ -117,7 +121,8 @@ inline void spdlog::logger::log(level::level_enum lvl, const T& msg)
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
_err_handler("Unknown exception");
|
||||
_err_handler("Unknown exception in logger " + _name);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
@ -158,78 +163,6 @@ inline void spdlog::logger::critical(const char* fmt, const Arg1 &arg1, const Ar
|
||||
log(level::critical, fmt, arg1, args...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
inline void spdlog::logger::log_if(const bool flag, level::level_enum lvl, const char* msg)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(lvl, msg);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void spdlog::logger::log_if(const bool flag, level::level_enum lvl, const T& msg)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(lvl, msg);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Arg1, typename... Args>
|
||||
inline void spdlog::logger::trace_if(const bool flag, const char* fmt, const Arg1 &arg1, const Args&... args)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(level::trace, fmt, arg1, args...);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Arg1, typename... Args>
|
||||
inline void spdlog::logger::debug_if(const bool flag, const char* fmt, const Arg1 &arg1, const Args&... args)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(level::debug, fmt, arg1, args...);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Arg1, typename... Args>
|
||||
inline void spdlog::logger::info_if(const bool flag, const char* fmt, const Arg1 &arg1, const Args&... args)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(level::info, fmt, arg1, args...);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Arg1, typename... Args>
|
||||
inline void spdlog::logger::warn_if(const bool flag, const char* fmt, const Arg1& arg1, const Args&... args)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(level::warn, fmt, arg1, args...);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Arg1, typename... Args>
|
||||
inline void spdlog::logger::error_if(const bool flag, const char* fmt, const Arg1 &arg1, const Args&... args)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(level::err, fmt, arg1, args...);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Arg1, typename... Args>
|
||||
inline void spdlog::logger::critical_if(const bool flag, const char* fmt, const Arg1 &arg1, const Args&... args)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(level::critical, fmt, arg1, args...);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
inline void spdlog::logger::trace(const T& msg)
|
||||
@ -269,63 +202,11 @@ inline void spdlog::logger::critical(const T& msg)
|
||||
log(level::critical, msg);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void spdlog::logger::trace_if(const bool flag, const T& msg)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(level::trace, msg);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void spdlog::logger::debug_if(const bool flag, const T& msg)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(level::debug, msg);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void spdlog::logger::info_if(const bool flag, const T& msg)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(level::info, msg);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void spdlog::logger::warn_if(const bool flag, const T& msg)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(level::warn, msg);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void spdlog::logger::error_if(const bool flag, const T& msg)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(level::err, msg);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void spdlog::logger::critical_if(const bool flag, const T& msg)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(level::critical, msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT
|
||||
#include <codecvt>
|
||||
#include <locale>
|
||||
|
||||
template <typename... Args>
|
||||
inline void spdlog::logger::log(level::level_enum lvl, const wchar_t* msg)
|
||||
@ -381,83 +262,6 @@ inline void spdlog::logger::critical(const wchar_t* fmt, const Args&... args)
|
||||
log(level::critical, fmt, args...);
|
||||
}
|
||||
|
||||
//
|
||||
// conditional logging
|
||||
//
|
||||
|
||||
template <typename... Args>
|
||||
inline void spdlog::logger::log_if(const bool flag, level::level_enum lvl, const wchar_t* msg)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(lvl, msg);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
inline void spdlog::logger::log_if(const bool flag, level::level_enum lvl, const wchar_t* fmt, const Args&... args)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(lvl, fmt, args);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
inline void spdlog::logger::trace_if(const bool flag, const wchar_t* fmt, const Args&... args)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(level::trace, fmt, args...);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
inline void spdlog::logger::debug_if(const bool flag, const wchar_t* fmt, const Args&... args)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(level::debug, fmt, args...);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
inline void spdlog::logger::info_if(const bool flag, const wchar_t* fmt, const Args&... args)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(level::info, fmt, args...);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <typename... Args>
|
||||
inline void spdlog::logger::warn_if(const bool flag, const wchar_t* fmt, const Args&... args)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(level::warn, fmt, args...);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
inline void spdlog::logger::error_if(const bool flag, const wchar_t* fmt, const Args&... args)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(level::err, fmt, args...);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
inline void spdlog::logger::critical_if(const bool flag, const wchar_t* fmt, const Args&... args)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(level::critical, fmt, args...);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // SPDLOG_WCHAR_TO_UTF8_SUPPORT
|
||||
|
||||
|
||||
@ -507,7 +311,7 @@ inline bool spdlog::logger::should_log(spdlog::level::level_enum msg_level) cons
|
||||
inline void spdlog::logger::_sink_it(details::log_msg& msg)
|
||||
{
|
||||
#if defined(SPDLOG_ENABLE_MESSAGE_COUNTER)
|
||||
msg.msg_id = _msg_counter.fetch_add(1, std::memory_order_relaxed);
|
||||
_incr_msg_counter(msg);
|
||||
#endif
|
||||
_formatter->format(msg);
|
||||
for (auto &sink : _sinks)
|
||||
@ -557,7 +361,13 @@ inline bool spdlog::logger::_should_flush_on(const details::log_msg &msg)
|
||||
return (msg.level >= flush_level) && (msg.level != level::off);
|
||||
}
|
||||
|
||||
inline void spdlog::logger::_incr_msg_counter(details::log_msg &msg)
|
||||
{
|
||||
msg.msg_id = _msg_counter.fetch_add(1, std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
inline const std::vector<spdlog::sink_ptr>& spdlog::logger::sinks() const
|
||||
{
|
||||
return _sinks;
|
||||
}
|
||||
|
||||
|
32
vendor/spdlog/spdlog/details/mpmc_bounded_q.h
vendored
32
vendor/spdlog/spdlog/details/mpmc_bounded_q.h
vendored
@ -43,7 +43,7 @@ Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "spdlog/common.h"
|
||||
#include "../common.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <utility>
|
||||
@ -61,11 +61,11 @@ public:
|
||||
using item_type = T;
|
||||
mpmc_bounded_queue(size_t buffer_size)
|
||||
:max_size_(buffer_size),
|
||||
buffer_(new cell_t [buffer_size]),
|
||||
buffer_(new cell_t[buffer_size]),
|
||||
buffer_mask_(buffer_size - 1)
|
||||
{
|
||||
//queue size must be power of two
|
||||
if(!((buffer_size >= 2) && ((buffer_size & (buffer_size - 1)) == 0)))
|
||||
if (!((buffer_size >= 2) && ((buffer_size & (buffer_size - 1)) == 0)))
|
||||
throw spdlog_ex("async logger queue size must be power of two");
|
||||
|
||||
for (size_t i = 0; i != buffer_size; i += 1)
|
||||
@ -76,7 +76,7 @@ public:
|
||||
|
||||
~mpmc_bounded_queue()
|
||||
{
|
||||
delete [] buffer_;
|
||||
delete[] buffer_;
|
||||
}
|
||||
|
||||
|
||||
@ -88,7 +88,7 @@ public:
|
||||
{
|
||||
cell = &buffer_[pos & buffer_mask_];
|
||||
size_t seq = cell->sequence_.load(std::memory_order_acquire);
|
||||
intptr_t dif = (intptr_t)seq - (intptr_t)pos;
|
||||
intptr_t dif = static_cast<intptr_t>(seq) - static_cast<intptr_t>(pos);
|
||||
if (dif == 0)
|
||||
{
|
||||
if (enqueue_pos_.compare_exchange_weak(pos, pos + 1, std::memory_order_relaxed))
|
||||
@ -117,7 +117,7 @@ public:
|
||||
cell = &buffer_[pos & buffer_mask_];
|
||||
size_t seq =
|
||||
cell->sequence_.load(std::memory_order_acquire);
|
||||
intptr_t dif = (intptr_t)seq - (intptr_t)(pos + 1);
|
||||
intptr_t dif = static_cast<intptr_t>(seq) - static_cast<intptr_t>(pos + 1);
|
||||
if (dif == 0)
|
||||
{
|
||||
if (dequeue_pos_.compare_exchange_weak(pos, pos + 1, std::memory_order_relaxed))
|
||||
@ -133,14 +133,18 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t approx_size()
|
||||
bool is_empty()
|
||||
{
|
||||
size_t first_pos = dequeue_pos_.load(std::memory_order_relaxed);
|
||||
size_t last_pos = enqueue_pos_.load(std::memory_order_relaxed);
|
||||
if (last_pos <= first_pos)
|
||||
return 0;
|
||||
auto size = last_pos - first_pos;
|
||||
return size < max_size_ ? size : max_size_;
|
||||
size_t front, front1, back;
|
||||
// try to take a consistent snapshot of front/tail.
|
||||
do
|
||||
{
|
||||
front = enqueue_pos_.load(std::memory_order_acquire);
|
||||
back = dequeue_pos_.load(std::memory_order_acquire);
|
||||
front1 = enqueue_pos_.load(std::memory_order_relaxed);
|
||||
}
|
||||
while (front != front1);
|
||||
return back == front;
|
||||
}
|
||||
|
||||
private:
|
||||
@ -153,7 +157,7 @@ private:
|
||||
size_t const max_size_;
|
||||
|
||||
static size_t const cacheline_size = 64;
|
||||
typedef char cacheline_pad_t [cacheline_size];
|
||||
typedef char cacheline_pad_t[cacheline_size];
|
||||
|
||||
cacheline_pad_t pad0_;
|
||||
cell_t* const buffer_;
|
||||
|
41
vendor/spdlog/spdlog/details/os.h
vendored
41
vendor/spdlog/spdlog/details/os.h
vendored
@ -4,7 +4,7 @@
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include "spdlog/common.h"
|
||||
#include "../common.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
@ -143,6 +143,16 @@ inline bool operator!=(const std::tm& tm1, const std::tm& tm2)
|
||||
SPDLOG_CONSTEXPR static const char* eol = SPDLOG_EOL;
|
||||
SPDLOG_CONSTEXPR static int eol_size = sizeof(SPDLOG_EOL) - 1;
|
||||
|
||||
|
||||
|
||||
// folder separator
|
||||
#ifdef _WIN32
|
||||
SPDLOG_CONSTEXPR static const char folder_sep = '\\';
|
||||
#else
|
||||
SPDLOG_CONSTEXPR static const char folder_sep = '/';
|
||||
#endif
|
||||
|
||||
|
||||
inline void prevent_child_fd(FILE *f)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
@ -221,7 +231,7 @@ inline size_t filesize(FILE *f)
|
||||
{
|
||||
if (f == nullptr)
|
||||
throw spdlog_ex("Failed getting file size. fd is null");
|
||||
#ifdef _WIN32
|
||||
#if defined ( _WIN32) && !defined(__CYGWIN__)
|
||||
int fd = _fileno(f);
|
||||
#if _WIN64 //64 bits
|
||||
struct _stat64 st;
|
||||
@ -236,12 +246,12 @@ inline size_t filesize(FILE *f)
|
||||
|
||||
#else // unix
|
||||
int fd = fileno(f);
|
||||
//64 bits(but not in osx, where fstat64 is deprecated)
|
||||
#if !defined(__FreeBSD__) && !defined(__APPLE__) && (defined(__x86_64__) || defined(__ppc64__))
|
||||
//64 bits(but not in osx or cygwin, where fstat64 is deprecated)
|
||||
#if !defined(__FreeBSD__) && !defined(__APPLE__) && (defined(__x86_64__) || defined(__ppc64__)) && !defined(__CYGWIN__)
|
||||
struct stat64 st;
|
||||
if (fstat64(fd, &st) == 0)
|
||||
return static_cast<size_t>(st.st_size);
|
||||
#else // unix 32 bits or osx
|
||||
#else // unix 32 bits or cygwin
|
||||
struct stat st;
|
||||
if (fstat(fd, &st) == 0)
|
||||
return static_cast<size_t>(st.st_size);
|
||||
@ -316,7 +326,7 @@ inline int utc_minutes_offset(const std::tm& tm = details::os::localtime())
|
||||
}
|
||||
|
||||
//Return current thread id as size_t
|
||||
//It exists because the std::this_thread::get_id() is much slower(espcially under VS 2013)
|
||||
//It exists because the std::this_thread::get_id() is much slower(especially under VS 2013)
|
||||
inline size_t _thread_id()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
@ -342,16 +352,27 @@ inline size_t _thread_id()
|
||||
//Return current thread id as size_t (from thread local storage)
|
||||
inline size_t thread_id()
|
||||
{
|
||||
#if defined(_MSC_VER) && (_MSC_VER < 1900) || defined(__clang__) && !__has_feature(cxx_thread_local)
|
||||
#if defined(SPDLOG_DISABLE_TID_CACHING) || (defined(_MSC_VER) && (_MSC_VER < 1900)) || (defined(__clang__) && !__has_feature(cxx_thread_local))
|
||||
return _thread_id();
|
||||
#else
|
||||
#else // cache thread id in tls
|
||||
static thread_local const size_t tid = _thread_id();
|
||||
return tid;
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// This is avoid msvc issue in sleep_for that happens if the clock changes.
|
||||
// See https://github.com/gabime/spdlog/issues/609
|
||||
inline void sleep_for_millis(int milliseconds)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
Sleep(milliseconds);
|
||||
#else
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds));
|
||||
#endif
|
||||
}
|
||||
|
||||
// wchar support for windows file names (SPDLOG_WCHAR_FILENAMES must be defined)
|
||||
#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
|
||||
@ -424,7 +445,7 @@ inline int pid()
|
||||
}
|
||||
|
||||
|
||||
// Detrmine if the terminal supports colors
|
||||
// Determine if the terminal supports colors
|
||||
// Source: https://github.com/agauniyal/rang/
|
||||
inline bool is_color_terminal()
|
||||
{
|
||||
|
@ -5,10 +5,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "spdlog/formatter.h"
|
||||
#include "spdlog/details/log_msg.h"
|
||||
#include "spdlog/details/os.h"
|
||||
#include "spdlog/fmt/fmt.h"
|
||||
#include "../formatter.h"
|
||||
#include "../details/log_msg.h"
|
||||
#include "../details/os.h"
|
||||
#include "../fmt/fmt.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <ctime>
|
||||
@ -99,7 +99,7 @@ class A_formatter:public flag_formatter
|
||||
};
|
||||
|
||||
//Abbreviated month
|
||||
static const std::string months[] { "Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec" };
|
||||
static const std::string months[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec" };
|
||||
class b_formatter:public flag_formatter
|
||||
{
|
||||
void format(details::log_msg& msg, const std::tm& tm_time) override
|
||||
@ -119,14 +119,14 @@ class B_formatter:public flag_formatter
|
||||
};
|
||||
|
||||
|
||||
//write 2 ints seperated by sep with padding of 2
|
||||
//write 2 ints separated by sep with padding of 2
|
||||
static fmt::MemoryWriter& pad_n_join(fmt::MemoryWriter& w, int v1, int v2, char sep)
|
||||
{
|
||||
w << fmt::pad(v1, 2, '0') << sep << fmt::pad(v2, 2, '0');
|
||||
return w;
|
||||
}
|
||||
|
||||
//write 3 ints seperated by sep with padding of 2
|
||||
//write 3 ints separated by sep with padding of 2
|
||||
static fmt::MemoryWriter& pad_n_join(fmt::MemoryWriter& w, int v1, int v2, int v3, char sep)
|
||||
{
|
||||
w << fmt::pad(v1, 2, '0') << sep << fmt::pad(v2, 2, '0') << sep << fmt::pad(v3, 2, '0');
|
||||
@ -262,6 +262,16 @@ class F_formatter SPDLOG_FINAL:public flag_formatter
|
||||
}
|
||||
};
|
||||
|
||||
class E_formatter SPDLOG_FINAL:public flag_formatter
|
||||
{
|
||||
void format(details::log_msg& msg, const std::tm&) override
|
||||
{
|
||||
auto duration = msg.time.time_since_epoch();
|
||||
auto seconds = std::chrono::duration_cast<std::chrono::seconds>(duration).count();
|
||||
msg.formatted << seconds;
|
||||
}
|
||||
};
|
||||
|
||||
// AM/PM
|
||||
class p_formatter SPDLOG_FINAL:public flag_formatter
|
||||
{
|
||||
@ -374,6 +384,14 @@ class pid_formatter SPDLOG_FINAL:public flag_formatter
|
||||
}
|
||||
};
|
||||
|
||||
// message counter formatter
|
||||
class i_formatter SPDLOG_FINAL :public flag_formatter
|
||||
{
|
||||
void format(details::log_msg& msg, const std::tm&) override
|
||||
{
|
||||
msg.formatted << fmt::pad(msg.msg_id, 6, '0');
|
||||
}
|
||||
};
|
||||
|
||||
class v_formatter SPDLOG_FINAL:public flag_formatter
|
||||
{
|
||||
@ -598,6 +616,10 @@ inline void spdlog::pattern_formatter::handle_flag(char flag)
|
||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::F_formatter()));
|
||||
break;
|
||||
|
||||
case('E'):
|
||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::E_formatter()));
|
||||
break;
|
||||
|
||||
case('p'):
|
||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::p_formatter()));
|
||||
break;
|
||||
@ -627,11 +649,10 @@ inline void spdlog::pattern_formatter::handle_flag(char flag)
|
||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::pid_formatter()));
|
||||
break;
|
||||
|
||||
#if defined(SPDLOG_ENABLE_MESSAGE_COUNTER)
|
||||
|
||||
case ('i'):
|
||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::i_formatter()));
|
||||
break;
|
||||
#endif
|
||||
|
||||
default: //Unknown flag appears as is
|
||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::ch_formatter('%')));
|
||||
|
19
vendor/spdlog/spdlog/details/registry.h
vendored
19
vendor/spdlog/spdlog/details/registry.h
vendored
@ -10,10 +10,10 @@
|
||||
// If user requests a non existing logger, nullptr will be returned
|
||||
// This class is thread safe
|
||||
|
||||
#include "spdlog/details/null_mutex.h"
|
||||
#include "spdlog/logger.h"
|
||||
#include "spdlog/async_logger.h"
|
||||
#include "spdlog/common.h"
|
||||
#include "../details/null_mutex.h"
|
||||
#include "../logger.h"
|
||||
#include "../async_logger.h"
|
||||
#include "../common.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
@ -64,6 +64,7 @@ public:
|
||||
new_logger->set_error_handler(_err_handler);
|
||||
|
||||
new_logger->set_level(_level);
|
||||
new_logger->flush_on(_flush_level);
|
||||
|
||||
|
||||
//Add to registry
|
||||
@ -85,6 +86,7 @@ public:
|
||||
new_logger->set_error_handler(_err_handler);
|
||||
|
||||
new_logger->set_level(_level);
|
||||
new_logger->flush_on(_flush_level);
|
||||
|
||||
//Add to registry
|
||||
_loggers[logger_name] = new_logger;
|
||||
@ -153,6 +155,14 @@ public:
|
||||
_level = log_level;
|
||||
}
|
||||
|
||||
void flush_on(level::level_enum log_level)
|
||||
{
|
||||
std::lock_guard<Mutex> lock(_mutex);
|
||||
for (auto& l : _loggers)
|
||||
l.second->flush_on(log_level);
|
||||
_flush_level = log_level;
|
||||
}
|
||||
|
||||
void set_error_handler(log_err_handler handler)
|
||||
{
|
||||
for (auto& l : _loggers)
|
||||
@ -197,6 +207,7 @@ private:
|
||||
std::unordered_map <std::string, std::shared_ptr<logger>> _loggers;
|
||||
formatter_ptr _formatter;
|
||||
level::level_enum _level = level::info;
|
||||
level::level_enum _flush_level = level::off;
|
||||
log_err_handler _err_handler;
|
||||
bool _async_mode = false;
|
||||
size_t _async_q_size = 0;
|
||||
|
25
vendor/spdlog/spdlog/details/spdlog_impl.h
vendored
25
vendor/spdlog/spdlog/details/spdlog_impl.h
vendored
@ -8,23 +8,23 @@
|
||||
//
|
||||
// Global registry functions
|
||||
//
|
||||
#include "spdlog/spdlog.h"
|
||||
#include "spdlog/details/registry.h"
|
||||
#include "spdlog/sinks/file_sinks.h"
|
||||
#include "spdlog/sinks/stdout_sinks.h"
|
||||
#include "../spdlog.h"
|
||||
#include "../details/registry.h"
|
||||
#include "../sinks/file_sinks.h"
|
||||
#include "../sinks/stdout_sinks.h"
|
||||
#ifdef SPDLOG_ENABLE_SYSLOG
|
||||
#include "spdlog/sinks/syslog_sink.h"
|
||||
#include "../sinks/syslog_sink.h"
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "spdlog/sinks/wincolor_sink.h"
|
||||
#include "../sinks/wincolor_sink.h"
|
||||
#else
|
||||
#include "spdlog/sinks/ansicolor_sink.h"
|
||||
#include "../sinks/ansicolor_sink.h"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __ANDROID__
|
||||
#include "spdlog/sinks/android_sink.h"
|
||||
#include "../sinks/android_sink.h"
|
||||
#endif
|
||||
|
||||
#include <chrono>
|
||||
@ -162,9 +162,9 @@ inline std::shared_ptr<spdlog::logger> spdlog::stderr_color_st(const std::string
|
||||
|
||||
#ifdef SPDLOG_ENABLE_SYSLOG
|
||||
// Create syslog logger
|
||||
inline std::shared_ptr<spdlog::logger> spdlog::syslog_logger(const std::string& logger_name, const std::string& syslog_ident, int syslog_option)
|
||||
inline std::shared_ptr<spdlog::logger> spdlog::syslog_logger(const std::string& logger_name, const std::string& syslog_ident, int syslog_option, int syslog_facility)
|
||||
{
|
||||
return create<spdlog::sinks::syslog_sink>(logger_name, syslog_ident, syslog_option);
|
||||
return create<spdlog::sinks::syslog_sink>(logger_name, syslog_ident, syslog_option, syslog_facility);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -236,6 +236,11 @@ inline void spdlog::set_level(level::level_enum log_level)
|
||||
return details::registry::instance().set_level(log_level);
|
||||
}
|
||||
|
||||
inline void spdlog::flush_on(level::level_enum log_level)
|
||||
{
|
||||
return details::registry::instance().flush_on(log_level);
|
||||
}
|
||||
|
||||
inline void spdlog::set_error_handler(log_err_handler handler)
|
||||
{
|
||||
return details::registry::instance().set_error_handler(handler);
|
||||
|
23
vendor/spdlog/spdlog/fmt/bundled/LICENSE.rst
vendored
Normal file
23
vendor/spdlog/spdlog/fmt/bundled/LICENSE.rst
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
Copyright (c) 2012 - 2016, Victor Zverovich
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
4977
vendor/spdlog/spdlog/fmt/bundled/format.h
vendored
4977
vendor/spdlog/spdlog/fmt/bundled/format.h
vendored
File diff suppressed because it is too large
Load Diff
93
vendor/spdlog/spdlog/fmt/bundled/ostream.h
vendored
93
vendor/spdlog/spdlog/fmt/bundled/ostream.h
vendored
@ -13,57 +13,65 @@
|
||||
#include "format.h"
|
||||
#include <ostream>
|
||||
|
||||
namespace fmt {
|
||||
namespace fmt
|
||||
{
|
||||
|
||||
namespace internal {
|
||||
namespace internal
|
||||
{
|
||||
|
||||
template <class Char>
|
||||
class FormatBuf : public std::basic_streambuf<Char> {
|
||||
private:
|
||||
typedef typename std::basic_streambuf<Char>::int_type int_type;
|
||||
typedef typename std::basic_streambuf<Char>::traits_type traits_type;
|
||||
class FormatBuf : public std::basic_streambuf<Char>
|
||||
{
|
||||
private:
|
||||
typedef typename std::basic_streambuf<Char>::int_type int_type;
|
||||
typedef typename std::basic_streambuf<Char>::traits_type traits_type;
|
||||
|
||||
Buffer<Char> &buffer_;
|
||||
Buffer<Char> &buffer_;
|
||||
|
||||
public:
|
||||
FormatBuf(Buffer<Char> &buffer) : buffer_(buffer) {}
|
||||
public:
|
||||
FormatBuf(Buffer<Char> &buffer) : buffer_(buffer) {}
|
||||
|
||||
protected:
|
||||
// The put-area is actually always empty. This makes the implementation
|
||||
// simpler and has the advantage that the streambuf and the buffer are always
|
||||
// in sync and sputc never writes into uninitialized memory. The obvious
|
||||
// disadvantage is that each call to sputc always results in a (virtual) call
|
||||
// to overflow. There is no disadvantage here for sputn since this always
|
||||
// results in a call to xsputn.
|
||||
protected:
|
||||
// The put-area is actually always empty. This makes the implementation
|
||||
// simpler and has the advantage that the streambuf and the buffer are always
|
||||
// in sync and sputc never writes into uninitialized memory. The obvious
|
||||
// disadvantage is that each call to sputc always results in a (virtual) call
|
||||
// to overflow. There is no disadvantage here for sputn since this always
|
||||
// results in a call to xsputn.
|
||||
|
||||
int_type overflow(int_type ch = traits_type::eof()) FMT_OVERRIDE {
|
||||
if (!traits_type::eq_int_type(ch, traits_type::eof()))
|
||||
buffer_.push_back(static_cast<Char>(ch));
|
||||
return ch;
|
||||
}
|
||||
int_type overflow(int_type ch = traits_type::eof()) FMT_OVERRIDE
|
||||
{
|
||||
if (!traits_type::eq_int_type(ch, traits_type::eof()))
|
||||
buffer_.push_back(static_cast<Char>(ch));
|
||||
return ch;
|
||||
}
|
||||
|
||||
std::streamsize xsputn(const Char *s, std::streamsize count) FMT_OVERRIDE {
|
||||
buffer_.append(s, s + count);
|
||||
return count;
|
||||
}
|
||||
std::streamsize xsputn(const Char *s, std::streamsize count) FMT_OVERRIDE
|
||||
{
|
||||
buffer_.append(s, s + count);
|
||||
return count;
|
||||
}
|
||||
};
|
||||
|
||||
Yes &convert(std::ostream &);
|
||||
|
||||
struct DummyStream : std::ostream {
|
||||
DummyStream(); // Suppress a bogus warning in MSVC.
|
||||
// Hide all operator<< overloads from std::ostream.
|
||||
void operator<<(Null<>);
|
||||
struct DummyStream : std::ostream
|
||||
{
|
||||
DummyStream(); // Suppress a bogus warning in MSVC.
|
||||
// Hide all operator<< overloads from std::ostream.
|
||||
void operator<<(Null<>);
|
||||
};
|
||||
|
||||
No &operator<<(std::ostream &, int);
|
||||
|
||||
template<typename T>
|
||||
struct ConvertToIntImpl<T, true> {
|
||||
// Convert to int only if T doesn't have an overloaded operator<<.
|
||||
enum {
|
||||
value = sizeof(convert(get<DummyStream>() << get<T>())) == sizeof(No)
|
||||
};
|
||||
struct ConvertToIntImpl<T, true>
|
||||
{
|
||||
// Convert to int only if T doesn't have an overloaded operator<<.
|
||||
enum
|
||||
{
|
||||
value = sizeof(convert(get<DummyStream>() << get<T>())) == sizeof(No)
|
||||
};
|
||||
};
|
||||
|
||||
// Write the content of w to os.
|
||||
@ -73,16 +81,17 @@ FMT_API void write(std::ostream &os, Writer &w);
|
||||
// Formats a value.
|
||||
template <typename Char, typename ArgFormatter_, typename T>
|
||||
void format_arg(BasicFormatter<Char, ArgFormatter_> &f,
|
||||
const Char *&format_str, const T &value) {
|
||||
internal::MemoryBuffer<Char, internal::INLINE_BUFFER_SIZE> buffer;
|
||||
const Char *&format_str, const T &value)
|
||||
{
|
||||
internal::MemoryBuffer<Char, internal::INLINE_BUFFER_SIZE> buffer;
|
||||
|
||||
internal::FormatBuf<Char> format_buf(buffer);
|
||||
std::basic_ostream<Char> output(&format_buf);
|
||||
output << value;
|
||||
internal::FormatBuf<Char> format_buf(buffer);
|
||||
std::basic_ostream<Char> output(&format_buf);
|
||||
output << value;
|
||||
|
||||
BasicStringRef<Char> str(&buffer[0], buffer.size());
|
||||
typedef internal::MakeArg< BasicFormatter<Char> > MakeArg;
|
||||
format_str = f.format(format_str, MakeArg(str));
|
||||
BasicStringRef<Char> str(&buffer[0], buffer.size());
|
||||
typedef internal::MakeArg< BasicFormatter<Char> > MakeArg;
|
||||
format_str = f.format(format_str, MakeArg(str));
|
||||
}
|
||||
|
||||
/**
|
||||
|
469
vendor/spdlog/spdlog/fmt/bundled/posix.h
vendored
469
vendor/spdlog/spdlog/fmt/bundled/posix.h
vendored
@ -64,112 +64,134 @@
|
||||
|
||||
#define FMT_RETRY(result, expression) FMT_RETRY_VAL(result, expression, -1)
|
||||
|
||||
namespace fmt {
|
||||
namespace fmt
|
||||
{
|
||||
|
||||
// An error code.
|
||||
class ErrorCode {
|
||||
private:
|
||||
int value_;
|
||||
class ErrorCode
|
||||
{
|
||||
private:
|
||||
int value_;
|
||||
|
||||
public:
|
||||
explicit ErrorCode(int value = 0) FMT_NOEXCEPT : value_(value) {}
|
||||
public:
|
||||
explicit ErrorCode(int value = 0) FMT_NOEXCEPT :
|
||||
value_(value) {}
|
||||
|
||||
int get() const FMT_NOEXCEPT { return value_; }
|
||||
int get() const FMT_NOEXCEPT
|
||||
{
|
||||
return value_;
|
||||
}
|
||||
};
|
||||
|
||||
// A buffered file.
|
||||
class BufferedFile {
|
||||
private:
|
||||
FILE *file_;
|
||||
class BufferedFile
|
||||
{
|
||||
private:
|
||||
FILE *file_;
|
||||
|
||||
friend class File;
|
||||
friend class File;
|
||||
|
||||
explicit BufferedFile(FILE *f) : file_(f) {}
|
||||
|
||||
public:
|
||||
// Constructs a BufferedFile object which doesn't represent any file.
|
||||
BufferedFile() FMT_NOEXCEPT : file_(FMT_NULL) {}
|
||||
|
||||
// Destroys the object closing the file it represents if any.
|
||||
FMT_API ~BufferedFile() FMT_NOEXCEPT;
|
||||
|
||||
#if !FMT_USE_RVALUE_REFERENCES
|
||||
// Emulate a move constructor and a move assignment operator if rvalue
|
||||
// references are not supported.
|
||||
|
||||
private:
|
||||
// A proxy object to emulate a move constructor.
|
||||
// It is private to make it impossible call operator Proxy directly.
|
||||
struct Proxy {
|
||||
FILE *file;
|
||||
};
|
||||
explicit BufferedFile(FILE *f) : file_(f) {}
|
||||
|
||||
public:
|
||||
// A "move constructor" for moving from a temporary.
|
||||
BufferedFile(Proxy p) FMT_NOEXCEPT : file_(p.file) {}
|
||||
// Constructs a BufferedFile object which doesn't represent any file.
|
||||
BufferedFile() FMT_NOEXCEPT :
|
||||
file_(FMT_NULL) {}
|
||||
|
||||
// A "move constructor" for moving from an lvalue.
|
||||
BufferedFile(BufferedFile &f) FMT_NOEXCEPT : file_(f.file_) {
|
||||
f.file_ = FMT_NULL;
|
||||
}
|
||||
// Destroys the object closing the file it represents if any.
|
||||
FMT_API ~BufferedFile() FMT_NOEXCEPT;
|
||||
|
||||
// A "move assignment operator" for moving from a temporary.
|
||||
BufferedFile &operator=(Proxy p) {
|
||||
close();
|
||||
file_ = p.file;
|
||||
return *this;
|
||||
}
|
||||
#if !FMT_USE_RVALUE_REFERENCES
|
||||
// Emulate a move constructor and a move assignment operator if rvalue
|
||||
// references are not supported.
|
||||
|
||||
// A "move assignment operator" for moving from an lvalue.
|
||||
BufferedFile &operator=(BufferedFile &other) {
|
||||
close();
|
||||
file_ = other.file_;
|
||||
other.file_ = FMT_NULL;
|
||||
return *this;
|
||||
}
|
||||
private:
|
||||
// A proxy object to emulate a move constructor.
|
||||
// It is private to make it impossible call operator Proxy directly.
|
||||
struct Proxy
|
||||
{
|
||||
FILE *file;
|
||||
};
|
||||
|
||||
// Returns a proxy object for moving from a temporary:
|
||||
// BufferedFile file = BufferedFile(...);
|
||||
operator Proxy() FMT_NOEXCEPT {
|
||||
Proxy p = {file_};
|
||||
file_ = FMT_NULL;
|
||||
return p;
|
||||
}
|
||||
public:
|
||||
// A "move constructor" for moving from a temporary.
|
||||
BufferedFile(Proxy p) FMT_NOEXCEPT :
|
||||
file_(p.file) {}
|
||||
|
||||
// A "move constructor" for moving from an lvalue.
|
||||
BufferedFile(BufferedFile &f) FMT_NOEXCEPT :
|
||||
file_(f.file_)
|
||||
{
|
||||
f.file_ = FMT_NULL;
|
||||
}
|
||||
|
||||
// A "move assignment operator" for moving from a temporary.
|
||||
BufferedFile &operator=(Proxy p)
|
||||
{
|
||||
close();
|
||||
file_ = p.file;
|
||||
return *this;
|
||||
}
|
||||
|
||||