|
|
|
@ -4,6 +4,18 @@
|
|
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
|
|
|
|
|
#ifdef __has_include
|
|
|
|
|
# if __has_include(<source_location>) && __cplusplus >= 202002L
|
|
|
|
|
# include <source_location>
|
|
|
|
|
# define SPDLOG_SOURCE_LOCATION
|
|
|
|
|
# endif
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef SPDLOG_SOURCE_LOCATION
|
|
|
|
|
namespace spdlog::details {
|
|
|
|
|
using source_location = std::source_location;
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
namespace spdlog {
|
|
|
|
|
namespace details {
|
|
|
|
|
struct source_location {
|
|
|
|
@ -12,28 +24,28 @@ public:
|
|
|
|
|
(__clang_major__ >= 9)
|
|
|
|
|
static constexpr source_location
|
|
|
|
|
current(const char *fileName = __builtin_FILE(),
|
|
|
|
|
const int lineNumber = __builtin_LINE(),
|
|
|
|
|
const unsigned lineNumber = __builtin_LINE(),
|
|
|
|
|
const char *functionName = __builtin_FUNCTION(),
|
|
|
|
|
const int columnOffset = __builtin_COLUMN()) noexcept
|
|
|
|
|
const unsigned columnOffset = __builtin_COLUMN()) noexcept
|
|
|
|
|
#elif defined(__GNUC__) && \
|
|
|
|
|
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
|
|
|
|
|
static constexpr source_location
|
|
|
|
|
current(const char *fileName = __builtin_FILE(),
|
|
|
|
|
const int lineNumber = __builtin_LINE(),
|
|
|
|
|
const unsigned lineNumber = __builtin_LINE(),
|
|
|
|
|
const char *functionName = __builtin_FUNCTION(),
|
|
|
|
|
const int columnOffset = 0) noexcept
|
|
|
|
|
const unsigned columnOffset = 0) noexcept
|
|
|
|
|
#elif defined(_MSC_VER) && (_MSC_VER > 1925)
|
|
|
|
|
static constexpr source_location
|
|
|
|
|
current(const char *fileName = __builtin_FILE(),
|
|
|
|
|
const int lineNumber = __builtin_LINE(),
|
|
|
|
|
const unsigned lineNumber = __builtin_LINE(),
|
|
|
|
|
const char *functionName = __builtin_FUNCTION(),
|
|
|
|
|
const int columnOffset = __builtin_COLUMN()) noexcept
|
|
|
|
|
const unsigned columnOffset = __builtin_COLUMN()) noexcept
|
|
|
|
|
#else
|
|
|
|
|
static constexpr source_location
|
|
|
|
|
current(const char *fileName = "unsupported",
|
|
|
|
|
const int lineNumber = 0,
|
|
|
|
|
const unsigned lineNumber = 0,
|
|
|
|
|
const char *functionName = "unsupported",
|
|
|
|
|
const int columnOffset = 0) noexcept
|
|
|
|
|
const unsigned columnOffset = 0) noexcept
|
|
|
|
|
#endif
|
|
|
|
|
{
|
|
|
|
|
return source_location(fileName, lineNumber, functionName, columnOffset);
|
|
|
|
@ -46,23 +58,23 @@ public:
|
|
|
|
|
|
|
|
|
|
constexpr const char *function_name() const noexcept { return functionName; }
|
|
|
|
|
|
|
|
|
|
constexpr int line() const noexcept { return lineNumber; }
|
|
|
|
|
constexpr unsigned line() const noexcept { return lineNumber; }
|
|
|
|
|
|
|
|
|
|
constexpr int column() const noexcept { return columnOffset; }
|
|
|
|
|
constexpr unsigned column() const noexcept { return columnOffset; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
constexpr source_location(const char *fileName,
|
|
|
|
|
const int lineNumber,
|
|
|
|
|
const unsigned lineNumber,
|
|
|
|
|
const char *functionName,
|
|
|
|
|
const int columnOffset) noexcept
|
|
|
|
|
const unsigned columnOffset) noexcept
|
|
|
|
|
: fileName(fileName), lineNumber(lineNumber), functionName(functionName),
|
|
|
|
|
columnOffset(columnOffset) {}
|
|
|
|
|
|
|
|
|
|
const char *fileName;
|
|
|
|
|
const int lineNumber;
|
|
|
|
|
const unsigned lineNumber;
|
|
|
|
|
const char *functionName;
|
|
|
|
|
const int columnOffset;
|
|
|
|
|
const unsigned columnOffset;
|
|
|
|
|
};
|
|
|
|
|
} // namespace details
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
} // namespace spdlog
|
|
|
|
|