mirror of
https://github.com/gabime/spdlog.git
synced 2025-03-28 17:02:40 +08:00
formatting
This commit is contained in:
parent
c739e68021
commit
56e4a201ec
@ -143,9 +143,11 @@ enum class pattern_time_type
|
||||
//
|
||||
// Log exception
|
||||
//
|
||||
namespace details { namespace os {
|
||||
namespace details {
|
||||
namespace os {
|
||||
std::string errno_str(int err_num);
|
||||
}} // namespace details::os
|
||||
}
|
||||
} // namespace details
|
||||
class spdlog_ex : public std::exception
|
||||
{
|
||||
public:
|
||||
|
@ -28,7 +28,8 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace spdlog { namespace details {
|
||||
namespace spdlog {
|
||||
namespace details {
|
||||
|
||||
class async_log_helper
|
||||
{
|
||||
@ -184,7 +185,8 @@ private:
|
||||
// wait until the queue is empty
|
||||
void wait_empty_q();
|
||||
};
|
||||
}} // namespace spdlog::details
|
||||
} // namespace details
|
||||
} // namespace spdlog
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// async_sink class implementation
|
||||
|
@ -19,7 +19,8 @@
|
||||
#include <thread>
|
||||
#include <tuple>
|
||||
|
||||
namespace spdlog { namespace details {
|
||||
namespace spdlog {
|
||||
namespace details {
|
||||
|
||||
class file_helper
|
||||
{
|
||||
@ -136,4 +137,5 @@ private:
|
||||
FILE *_fd{nullptr};
|
||||
filename_t _filename;
|
||||
};
|
||||
}} // namespace spdlog::details
|
||||
} // namespace details
|
||||
} // namespace spdlog
|
||||
|
@ -11,7 +11,8 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace spdlog { namespace details {
|
||||
namespace spdlog {
|
||||
namespace details {
|
||||
struct log_msg
|
||||
{
|
||||
log_msg() = default;
|
||||
@ -40,4 +41,5 @@ struct log_msg
|
||||
fmt::MemoryWriter formatted;
|
||||
size_t msg_id{0};
|
||||
};
|
||||
}} // namespace spdlog::details
|
||||
} // namespace details
|
||||
} // namespace spdlog
|
||||
|
@ -48,7 +48,8 @@ Distributed under the MIT License (http://opensource.org/licenses/MIT)
|
||||
#include <atomic>
|
||||
#include <utility>
|
||||
|
||||
namespace spdlog { namespace details {
|
||||
namespace spdlog {
|
||||
namespace details {
|
||||
|
||||
template<typename T>
|
||||
class mpmc_bounded_queue
|
||||
@ -166,4 +167,5 @@ private:
|
||||
cacheline_pad_t pad3_;
|
||||
};
|
||||
|
||||
}} // namespace spdlog::details
|
||||
} // namespace details
|
||||
} // namespace spdlog
|
||||
|
@ -8,7 +8,8 @@
|
||||
#include <atomic>
|
||||
// null, no cost dummy "mutex" and dummy "atomic" int
|
||||
|
||||
namespace spdlog { namespace details {
|
||||
namespace spdlog {
|
||||
namespace details {
|
||||
struct null_mutex
|
||||
{
|
||||
void lock() {}
|
||||
@ -40,4 +41,5 @@ struct null_atomic_int
|
||||
}
|
||||
};
|
||||
|
||||
}} // namespace spdlog::details
|
||||
} // namespace details
|
||||
} // namespace spdlog
|
||||
|
@ -53,7 +53,9 @@
|
||||
#define __has_feature(x) 0 // Compatibility with non-clang compilers.
|
||||
#endif
|
||||
|
||||
namespace spdlog { namespace details { namespace os {
|
||||
namespace spdlog {
|
||||
namespace details {
|
||||
namespace os {
|
||||
|
||||
inline spdlog::log_clock::time_point now()
|
||||
{
|
||||
@ -445,4 +447,6 @@ inline bool in_terminal(FILE *file)
|
||||
return isatty(fileno(file)) != 0;
|
||||
#endif
|
||||
}
|
||||
}}} // namespace spdlog::details::os
|
||||
} // namespace os
|
||||
} // namespace details
|
||||
} // namespace spdlog
|
||||
|
@ -20,7 +20,8 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace spdlog { namespace details {
|
||||
namespace spdlog {
|
||||
namespace details {
|
||||
class flag_formatter
|
||||
{
|
||||
public:
|
||||
@ -466,7 +467,8 @@ class full_formatter SPDLOG_FINAL : public flag_formatter
|
||||
}
|
||||
};
|
||||
|
||||
}} // namespace spdlog::details
|
||||
} // namespace details
|
||||
} // namespace spdlog
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// pattern_formatter inline impl
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -22,7 +22,8 @@
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace spdlog { namespace details {
|
||||
namespace spdlog {
|
||||
namespace details {
|
||||
template<class Mutex>
|
||||
class registry_t
|
||||
{
|
||||
@ -232,4 +233,5 @@ using registry = registry_t<spdlog::details::null_mutex>;
|
||||
using registry = registry_t<std::mutex>;
|
||||
#endif
|
||||
|
||||
}} // namespace spdlog::details
|
||||
} // namespace details
|
||||
} // namespace spdlog
|
||||
|
@ -345,7 +345,8 @@ typedef __int64 intmax_t;
|
||||
#if FMT_MSC_VER && !defined(FMT_BUILTIN_CLZLL) && !defined(_MANAGED)
|
||||
#include <intrin.h> // _BitScanReverse, _BitScanReverse64
|
||||
|
||||
namespace fmt { namespace internal {
|
||||
namespace fmt {
|
||||
namespace internal {
|
||||
// avoid Clang with Microsoft CodeGen's -Wunknown-pragmas warning
|
||||
#ifndef __clang__
|
||||
#pragma intrinsic(_BitScanReverse)
|
||||
@ -391,10 +392,12 @@ inline uint32_t clzll(uint64_t x)
|
||||
return 63 - r;
|
||||
}
|
||||
#define FMT_BUILTIN_CLZLL(n) fmt::internal::clzll(n)
|
||||
}} // namespace fmt::internal
|
||||
} // namespace internal
|
||||
} // namespace fmt
|
||||
#endif
|
||||
|
||||
namespace fmt { namespace internal {
|
||||
namespace fmt {
|
||||
namespace internal {
|
||||
struct DummyInt
|
||||
{
|
||||
int data[2];
|
||||
@ -439,7 +442,8 @@ inline T const_check(T value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}} // namespace fmt::internal
|
||||
} // namespace internal
|
||||
} // namespace fmt
|
||||
|
||||
namespace std {
|
||||
// Standard permits specialization of std::numeric_limits. This specialization
|
||||
|
@ -20,7 +20,8 @@
|
||||
#define SPDLOG_ANDROID_RETRIES 2
|
||||
#endif
|
||||
|
||||
namespace spdlog { namespace sinks {
|
||||
namespace spdlog {
|
||||
namespace sinks {
|
||||
|
||||
/*
|
||||
* Android sink (logging using __android_log_write)
|
||||
@ -84,6 +85,7 @@ private:
|
||||
bool _use_raw_msg;
|
||||
};
|
||||
|
||||
}} // namespace spdlog::sinks
|
||||
} // namespace sinks
|
||||
} // namespace spdlog
|
||||
|
||||
#endif
|
||||
|
@ -12,7 +12,8 @@
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace spdlog { namespace sinks {
|
||||
namespace spdlog {
|
||||
namespace sinks {
|
||||
|
||||
/**
|
||||
* This sink prefixes the output with an ANSI escape sequence color code depending on the severity
|
||||
@ -133,4 +134,5 @@ public:
|
||||
using ansicolor_stderr_sink_mt = ansicolor_stderr_sink<std::mutex>;
|
||||
using ansicolor_stderr_sink_st = ansicolor_stderr_sink<details::null_mutex>;
|
||||
|
||||
}} // namespace spdlog::sinks
|
||||
} // namespace sinks
|
||||
} // namespace spdlog
|
||||
|
@ -17,7 +17,8 @@
|
||||
|
||||
#include <mutex>
|
||||
|
||||
namespace spdlog { namespace sinks {
|
||||
namespace spdlog {
|
||||
namespace sinks {
|
||||
template<class Mutex>
|
||||
class base_sink : public sink
|
||||
{
|
||||
@ -44,4 +45,5 @@ protected:
|
||||
virtual void _flush() = 0;
|
||||
Mutex _mutex;
|
||||
};
|
||||
}} // namespace spdlog::sinks
|
||||
} // namespace sinks
|
||||
} // namespace spdlog
|
||||
|
@ -17,7 +17,8 @@
|
||||
|
||||
// Distribution sink (mux). Stores a vector of sinks which get called when log is called
|
||||
|
||||
namespace spdlog { namespace sinks {
|
||||
namespace spdlog {
|
||||
namespace sinks {
|
||||
template<class Mutex>
|
||||
class dist_sink : public base_sink<Mutex>
|
||||
{
|
||||
@ -66,4 +67,5 @@ public:
|
||||
using dist_sink_mt = dist_sink<std::mutex>;
|
||||
using dist_sink_st = dist_sink<details::null_mutex>;
|
||||
|
||||
}} // namespace spdlog::sinks
|
||||
} // namespace sinks
|
||||
} // namespace spdlog
|
||||
|
@ -18,7 +18,8 @@
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
namespace spdlog { namespace sinks {
|
||||
namespace spdlog {
|
||||
namespace sinks {
|
||||
/*
|
||||
* Trivial file sink with single file as target
|
||||
*/
|
||||
@ -246,4 +247,5 @@ private:
|
||||
using daily_file_sink_mt = daily_file_sink<std::mutex>;
|
||||
using daily_file_sink_st = daily_file_sink<details::null_mutex>;
|
||||
|
||||
}} // namespace spdlog::sinks
|
||||
} // namespace sinks
|
||||
} // namespace spdlog
|
||||
|
@ -15,7 +15,8 @@
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
namespace spdlog { namespace sinks {
|
||||
namespace spdlog {
|
||||
namespace sinks {
|
||||
/*
|
||||
* MSVC sink (logging using OutputDebugStringA)
|
||||
*/
|
||||
@ -37,6 +38,7 @@ protected:
|
||||
using msvc_sink_mt = msvc_sink<std::mutex>;
|
||||
using msvc_sink_st = msvc_sink<details::null_mutex>;
|
||||
|
||||
}} // namespace spdlog::sinks
|
||||
} // namespace sinks
|
||||
} // namespace spdlog
|
||||
|
||||
#endif
|
||||
|
@ -10,7 +10,8 @@
|
||||
|
||||
#include <mutex>
|
||||
|
||||
namespace spdlog { namespace sinks {
|
||||
namespace spdlog {
|
||||
namespace sinks {
|
||||
|
||||
template<class Mutex>
|
||||
class null_sink : public base_sink<Mutex>
|
||||
@ -24,4 +25,5 @@ protected:
|
||||
using null_sink_mt = null_sink<details::null_mutex>;
|
||||
using null_sink_st = null_sink<details::null_mutex>;
|
||||
|
||||
}} // namespace spdlog::sinks
|
||||
} // namespace sinks
|
||||
} // namespace spdlog
|
||||
|
@ -11,7 +11,8 @@
|
||||
#include <mutex>
|
||||
#include <ostream>
|
||||
|
||||
namespace spdlog { namespace sinks {
|
||||
namespace spdlog {
|
||||
namespace sinks {
|
||||
template<class Mutex>
|
||||
class ostream_sink : public base_sink<Mutex>
|
||||
{
|
||||
@ -44,4 +45,5 @@ protected:
|
||||
using ostream_sink_mt = ostream_sink<std::mutex>;
|
||||
using ostream_sink_st = ostream_sink<details::null_mutex>;
|
||||
|
||||
}} // namespace spdlog::sinks
|
||||
} // namespace sinks
|
||||
} // namespace spdlog
|
||||
|
@ -7,7 +7,8 @@
|
||||
|
||||
#include "../details/log_msg.h"
|
||||
|
||||
namespace spdlog { namespace sinks {
|
||||
namespace spdlog {
|
||||
namespace sinks {
|
||||
class sink
|
||||
{
|
||||
public:
|
||||
@ -39,4 +40,5 @@ inline level::level_enum sink::level() const
|
||||
return static_cast<spdlog::level::level_enum>(_level.load(std::memory_order_relaxed));
|
||||
}
|
||||
|
||||
}} // namespace spdlog::sinks
|
||||
} // namespace sinks
|
||||
} // namespace spdlog
|
||||
|
@ -12,7 +12,8 @@
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
namespace spdlog { namespace sinks {
|
||||
namespace spdlog {
|
||||
namespace sinks {
|
||||
|
||||
template<class Mutex>
|
||||
class stdout_sink SPDLOG_FINAL : public base_sink<Mutex>
|
||||
@ -74,4 +75,5 @@ protected:
|
||||
using stderr_sink_mt = stderr_sink<std::mutex>;
|
||||
using stderr_sink_st = stderr_sink<details::null_mutex>;
|
||||
|
||||
}} // namespace spdlog::sinks
|
||||
} // namespace sinks
|
||||
} // namespace spdlog
|
||||
|
@ -16,7 +16,8 @@
|
||||
#include <string>
|
||||
#include <syslog.h>
|
||||
|
||||
namespace spdlog { namespace sinks {
|
||||
namespace spdlog {
|
||||
namespace sinks {
|
||||
/**
|
||||
* Sink that write to syslog using the `syscall()` library call.
|
||||
*
|
||||
@ -69,6 +70,7 @@ private:
|
||||
return _priorities[static_cast<size_t>(msg.level)];
|
||||
}
|
||||
};
|
||||
}} // namespace spdlog::sinks
|
||||
} // namespace sinks
|
||||
} // namespace spdlog
|
||||
|
||||
#endif
|
||||
|
@ -14,7 +14,8 @@
|
||||
#include <unordered_map>
|
||||
#include <wincon.h>
|
||||
|
||||
namespace spdlog { namespace sinks {
|
||||
namespace spdlog {
|
||||
namespace sinks {
|
||||
/*
|
||||
* Windows color console sink. Uses WriteConsoleA to write to the console with colors
|
||||
*/
|
||||
@ -119,4 +120,5 @@ public:
|
||||
using wincolor_stderr_sink_mt = wincolor_stderr_sink<std::mutex>;
|
||||
using wincolor_stderr_sink_st = wincolor_stderr_sink<details::null_mutex>;
|
||||
|
||||
}} // namespace spdlog::sinks
|
||||
} // namespace sinks
|
||||
} // namespace spdlog
|
||||
|
@ -9,7 +9,8 @@
|
||||
|
||||
#include "msvc_sink.h"
|
||||
|
||||
namespace spdlog { namespace sinks {
|
||||
namespace spdlog {
|
||||
namespace sinks {
|
||||
|
||||
/*
|
||||
* Windows debug sink (logging using OutputDebugStringA, synonym for msvc_sink)
|
||||
@ -20,6 +21,7 @@ using windebug_sink = msvc_sink<Mutex>;
|
||||
using windebug_sink_mt = msvc_sink_mt;
|
||||
using windebug_sink_st = msvc_sink_st;
|
||||
|
||||
}} // namespace spdlog::sinks
|
||||
} // namespace sinks
|
||||
} // namespace spdlog
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user