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