Moved namespace fmt to be under spdlog::details to minimize namespace pollution for the users
This commit is contained in:
parent
5cf9437ae7
commit
d817994bd2
@ -1,5 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
Formatting library for C++
|
|
||||||
|
Modified version of cppformat formatting library
|
||||||
|
|
||||||
|
Orginal license:
|
||||||
|
|
||||||
Copyright (c) 2012 - 2014, Victor Zverovich
|
Copyright (c) 2012 - 2014, Victor Zverovich
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
@ -49,9 +52,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
# undef ERROR
|
# undef ERROR
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using fmt::LongLong;
|
using spdlog::details::fmt::LongLong;
|
||||||
using fmt::ULongLong;
|
using spdlog::details::fmt::ULongLong;
|
||||||
using fmt::internal::Arg;
|
using spdlog::details::fmt::internal::Arg;
|
||||||
|
|
||||||
// Check if exceptions are disabled.
|
// Check if exceptions are disabled.
|
||||||
#if __GNUC__ && !__EXCEPTIONS
|
#if __GNUC__ && !__EXCEPTIONS
|
||||||
@ -127,7 +130,7 @@ struct IntChecker<true> {
|
|||||||
|
|
||||||
const char RESET_COLOR[] = "\x1b[0m";
|
const char RESET_COLOR[] = "\x1b[0m";
|
||||||
|
|
||||||
typedef void(*FormatFunc)(fmt::Writer &, int, fmt::StringRef);
|
typedef void(*FormatFunc)(spdlog::details::fmt::Writer &, int, spdlog::details::fmt::StringRef);
|
||||||
|
|
||||||
// Portable thread-safe version of strerror.
|
// Portable thread-safe version of strerror.
|
||||||
// Sets buffer to point to a string describing the error code.
|
// Sets buffer to point to a string describing the error code.
|
||||||
@ -166,27 +169,27 @@ FMT_FUNC int safe_strerror(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
FMT_FUNC void format_error_code(fmt::Writer &out, int error_code,
|
FMT_FUNC void format_error_code(spdlog::details::fmt::Writer &out, int error_code,
|
||||||
fmt::StringRef message) FMT_NOEXCEPT(true) {
|
spdlog::details::fmt::StringRef message) FMT_NOEXCEPT(true) {
|
||||||
// Report error code making sure that the output fits into
|
// Report error code making sure that the output fits into
|
||||||
// INLINE_BUFFER_SIZE to avoid dynamic memory allocation and potential
|
// INLINE_BUFFER_SIZE to avoid dynamic memory allocation and potential
|
||||||
// bad_alloc.
|
// bad_alloc.
|
||||||
out.clear();
|
out.clear();
|
||||||
static const char SEP[] = ": ";
|
static const char SEP[] = ": ";
|
||||||
static const char ERROR[] = "error ";
|
static const char ERROR[] = "error ";
|
||||||
fmt::internal::IntTraits<int>::MainType ec_value = error_code;
|
spdlog::details::fmt::internal::IntTraits<int>::MainType ec_value = error_code;
|
||||||
// Subtract 2 to account for terminating null characters in SEP and ERROR.
|
// Subtract 2 to account for terminating null characters in SEP and ERROR.
|
||||||
std::size_t error_code_size =
|
std::size_t error_code_size =
|
||||||
sizeof(SEP) + sizeof(ERROR) + fmt::internal::count_digits(ec_value) - 2;
|
sizeof(SEP) + sizeof(ERROR) + spdlog::details::fmt::internal::count_digits(ec_value) - 2;
|
||||||
if (message.size() <= fmt::internal::INLINE_BUFFER_SIZE - error_code_size)
|
if (message.size() <= spdlog::details::fmt::internal::INLINE_BUFFER_SIZE - error_code_size)
|
||||||
out << message << SEP;
|
out << message << SEP;
|
||||||
out << ERROR << error_code;
|
out << ERROR << error_code;
|
||||||
assert(out.size() <= fmt::internal::INLINE_BUFFER_SIZE);
|
assert(out.size() <= spdlog::details::fmt::internal::INLINE_BUFFER_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
FMT_FUNC void report_error(FormatFunc func,
|
FMT_FUNC void report_error(FormatFunc func,
|
||||||
int error_code, fmt::StringRef message) FMT_NOEXCEPT(true) {
|
int error_code, spdlog::details::fmt::StringRef message) FMT_NOEXCEPT(true) {
|
||||||
fmt::MemoryWriter full_message;
|
spdlog::details::fmt::MemoryWriter full_message;
|
||||||
func(full_message, error_code, message);
|
func(full_message, error_code, message);
|
||||||
// Use Writer::data instead of Writer::c_str to avoid potential memory
|
// Use Writer::data instead of Writer::c_str to avoid potential memory
|
||||||
// allocation.
|
// allocation.
|
||||||
@ -195,7 +198,7 @@ FMT_FUNC void report_error(FormatFunc func,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// IsZeroInt::visit(arg) returns true iff arg is a zero integer.
|
// IsZeroInt::visit(arg) returns true iff arg is a zero integer.
|
||||||
class IsZeroInt : public fmt::internal::ArgVisitor<IsZeroInt, bool> {
|
class IsZeroInt : public spdlog::details::fmt::internal::ArgVisitor<IsZeroInt, bool> {
|
||||||
public:
|
public:
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool visit_any_int(T value) {
|
bool visit_any_int(T value) {
|
||||||
@ -219,15 +222,15 @@ FMT_FUNC int parse_nonnegative_int(const Char *&s) {
|
|||||||
value = new_value;
|
value = new_value;
|
||||||
} while ('0' <= *s && *s <= '9');
|
} while ('0' <= *s && *s <= '9');
|
||||||
if (value > INT_MAX)
|
if (value > INT_MAX)
|
||||||
FMT_THROW(fmt::FormatError("number is too big"));
|
FMT_THROW(spdlog::details::fmt::FormatError("number is too big"));
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void require_numeric_argument(const Arg &arg, char spec) {
|
inline void require_numeric_argument(const Arg &arg, char spec) {
|
||||||
if (arg.type > Arg::LAST_NUMERIC_TYPE) {
|
if (arg.type > Arg::LAST_NUMERIC_TYPE) {
|
||||||
std::string message =
|
std::string message =
|
||||||
fmt::format("format specifier '{}' requires numeric argument", spec);
|
spdlog::details::fmt::format("format specifier '{}' requires numeric argument", spec);
|
||||||
FMT_THROW(fmt::FormatError(message));
|
FMT_THROW(spdlog::details::fmt::FormatError(message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,71 +239,71 @@ FMT_FUNC void check_sign(const Char *&s, const Arg &arg) {
|
|||||||
char sign = static_cast<char>(*s);
|
char sign = static_cast<char>(*s);
|
||||||
require_numeric_argument(arg, sign);
|
require_numeric_argument(arg, sign);
|
||||||
if (arg.type == Arg::UINT || arg.type == Arg::ULONG_LONG) {
|
if (arg.type == Arg::UINT || arg.type == Arg::ULONG_LONG) {
|
||||||
FMT_THROW(fmt::FormatError(fmt::format(
|
FMT_THROW(spdlog::details::fmt::FormatError(spdlog::details::fmt::format(
|
||||||
"format specifier '{}' requires signed argument", sign)));
|
"format specifier '{}' requires signed argument", sign)));
|
||||||
}
|
}
|
||||||
++s;
|
++s;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks if an argument is a valid printf width specifier and sets
|
// Checks if an argument is a valid printf width specifier and sets
|
||||||
// left alignment if it is negative.
|
// left alignment if it is negative.
|
||||||
class WidthHandler : public fmt::internal::ArgVisitor<WidthHandler, unsigned> {
|
class WidthHandler : public spdlog::details::fmt::internal::ArgVisitor<WidthHandler, unsigned> {
|
||||||
private:
|
private:
|
||||||
fmt::FormatSpec &spec_;
|
spdlog::details::fmt::FormatSpec &spec_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit WidthHandler(fmt::FormatSpec &spec) : spec_(spec) {}
|
explicit WidthHandler(spdlog::details::fmt::FormatSpec &spec) : spec_(spec) {}
|
||||||
|
|
||||||
unsigned visit_unhandled_arg() {
|
unsigned visit_unhandled_arg() {
|
||||||
FMT_THROW(fmt::FormatError("width is not integer"));
|
FMT_THROW(spdlog::details::fmt::FormatError("width is not integer"));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
unsigned visit_any_int(T value) {
|
unsigned visit_any_int(T value) {
|
||||||
typedef typename fmt::internal::IntTraits<T>::MainType UnsignedType;
|
typedef typename spdlog::details::fmt::internal::IntTraits<T>::MainType UnsignedType;
|
||||||
UnsignedType width = value;
|
UnsignedType width = value;
|
||||||
if (fmt::internal::is_negative(value)) {
|
if (spdlog::details::fmt::internal::is_negative(value)) {
|
||||||
spec_.align_ = fmt::ALIGN_LEFT;
|
spec_.align_ = spdlog::details::fmt::ALIGN_LEFT;
|
||||||
width = 0 - width;
|
width = 0 - width;
|
||||||
}
|
}
|
||||||
if (width > INT_MAX)
|
if (width > INT_MAX)
|
||||||
FMT_THROW(fmt::FormatError("number is too big"));
|
FMT_THROW(spdlog::details::fmt::FormatError("number is too big"));
|
||||||
return static_cast<unsigned>(width);
|
return static_cast<unsigned>(width);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class PrecisionHandler :
|
class PrecisionHandler :
|
||||||
public fmt::internal::ArgVisitor<PrecisionHandler, int> {
|
public spdlog::details::fmt::internal::ArgVisitor<PrecisionHandler, int> {
|
||||||
public:
|
public:
|
||||||
unsigned visit_unhandled_arg() {
|
unsigned visit_unhandled_arg() {
|
||||||
FMT_THROW(fmt::FormatError("precision is not integer"));
|
FMT_THROW(spdlog::details::fmt::FormatError("precision is not integer"));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
int visit_any_int(T value) {
|
int visit_any_int(T value) {
|
||||||
if (!IntChecker<std::numeric_limits<T>::is_signed>::fits_in_int(value))
|
if (!IntChecker<std::numeric_limits<T>::is_signed>::fits_in_int(value))
|
||||||
FMT_THROW(fmt::FormatError("number is too big"));
|
FMT_THROW(spdlog::details::fmt::FormatError("number is too big"));
|
||||||
return static_cast<int>(value);
|
return static_cast<int>(value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Converts an integer argument to an integral type T for printf.
|
// Converts an integer argument to an integral type T for printf.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class ArgConverter : public fmt::internal::ArgVisitor<ArgConverter<T>, void> {
|
class ArgConverter : public spdlog::details::fmt::internal::ArgVisitor<ArgConverter<T>, void> {
|
||||||
private:
|
private:
|
||||||
fmt::internal::Arg &arg_;
|
spdlog::details::fmt::internal::Arg &arg_;
|
||||||
wchar_t type_;
|
wchar_t type_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ArgConverter(fmt::internal::Arg &arg, wchar_t type)
|
ArgConverter(spdlog::details::fmt::internal::Arg &arg, wchar_t type)
|
||||||
: arg_(arg), type_(type) {}
|
: arg_(arg), type_(type) {}
|
||||||
|
|
||||||
template <typename U>
|
template <typename U>
|
||||||
void visit_any_int(U value) {
|
void visit_any_int(U value) {
|
||||||
bool is_signed = type_ == 'd' || type_ == 'i';
|
bool is_signed = type_ == 'd' || type_ == 'i';
|
||||||
using fmt::internal::Arg;
|
using spdlog::details::fmt::internal::Arg;
|
||||||
if (sizeof(T) <= sizeof(int)) {
|
if (sizeof(T) <= sizeof(int)) {
|
||||||
// Extra casts are used to silence warnings.
|
// Extra casts are used to silence warnings.
|
||||||
if (is_signed) {
|
if (is_signed) {
|
||||||
@ -310,31 +313,31 @@ public:
|
|||||||
else {
|
else {
|
||||||
arg_.type = Arg::UINT;
|
arg_.type = Arg::UINT;
|
||||||
arg_.uint_value = static_cast<unsigned>(
|
arg_.uint_value = static_cast<unsigned>(
|
||||||
static_cast<typename fmt::internal::MakeUnsigned<T>::Type>(value));
|
static_cast<typename spdlog::details::fmt::internal::MakeUnsigned<T>::Type>(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (is_signed) {
|
if (is_signed) {
|
||||||
arg_.type = Arg::LONG_LONG;
|
arg_.type = Arg::LONG_LONG;
|
||||||
arg_.long_long_value =
|
arg_.long_long_value =
|
||||||
static_cast<typename fmt::internal::MakeUnsigned<U>::Type>(value);
|
static_cast<typename spdlog::details::fmt::internal::MakeUnsigned<U>::Type>(value);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
arg_.type = Arg::ULONG_LONG;
|
arg_.type = Arg::ULONG_LONG;
|
||||||
arg_.ulong_long_value =
|
arg_.ulong_long_value =
|
||||||
static_cast<typename fmt::internal::MakeUnsigned<U>::Type>(value);
|
static_cast<typename spdlog::details::fmt::internal::MakeUnsigned<U>::Type>(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Converts an integer argument to char for printf.
|
// Converts an integer argument to char for printf.
|
||||||
class CharConverter : public fmt::internal::ArgVisitor<CharConverter, void> {
|
class CharConverter : public spdlog::details::fmt::internal::ArgVisitor<CharConverter, void> {
|
||||||
private:
|
private:
|
||||||
fmt::internal::Arg &arg_;
|
spdlog::details::fmt::internal::Arg &arg_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CharConverter(fmt::internal::Arg &arg) : arg_(arg) {}
|
explicit CharConverter(spdlog::details::fmt::internal::Arg &arg) : arg_(arg) {}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void visit_any_int(T value) {
|
void visit_any_int(T value) {
|
||||||
@ -362,7 +365,7 @@ inline Arg::StringValue<wchar_t> ignore_incompatible_str(
|
|||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
FMT_FUNC void fmt::SystemError::init(
|
FMT_FUNC void spdlog::details::fmt::SystemError::init(
|
||||||
int error_code, StringRef format_str, ArgList args) {
|
int error_code, StringRef format_str, ArgList args) {
|
||||||
error_code_ = error_code;
|
error_code_ = error_code;
|
||||||
MemoryWriter w;
|
MemoryWriter w;
|
||||||
@ -372,7 +375,7 @@ FMT_FUNC void fmt::SystemError::init(
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
FMT_FUNC int fmt::internal::CharTraits<char>::format_float(
|
FMT_FUNC int spdlog::details::fmt::internal::CharTraits<char>::format_float(
|
||||||
char *buffer, std::size_t size, const char *format,
|
char *buffer, std::size_t size, const char *format,
|
||||||
unsigned width, int precision, T value) {
|
unsigned width, int precision, T value) {
|
||||||
if (width == 0) {
|
if (width == 0) {
|
||||||
@ -386,7 +389,7 @@ FMT_FUNC int fmt::internal::CharTraits<char>::format_float(
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
FMT_FUNC int fmt::internal::CharTraits<wchar_t>::format_float(
|
FMT_FUNC int spdlog::details::fmt::internal::CharTraits<wchar_t>::format_float(
|
||||||
wchar_t *buffer, std::size_t size, const wchar_t *format,
|
wchar_t *buffer, std::size_t size, const wchar_t *format,
|
||||||
unsigned width, int precision, T value) {
|
unsigned width, int precision, T value) {
|
||||||
if (width == 0) {
|
if (width == 0) {
|
||||||
@ -400,7 +403,7 @@ FMT_FUNC int fmt::internal::CharTraits<wchar_t>::format_float(
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
const char fmt::internal::BasicData<T>::DIGITS[] =
|
const char spdlog::details::fmt::internal::BasicData<T>::DIGITS[] =
|
||||||
"0001020304050607080910111213141516171819"
|
"0001020304050607080910111213141516171819"
|
||||||
"2021222324252627282930313233343536373839"
|
"2021222324252627282930313233343536373839"
|
||||||
"4041424344454647484950515253545556575859"
|
"4041424344454647484950515253545556575859"
|
||||||
@ -419,12 +422,12 @@ const char fmt::internal::BasicData<T>::DIGITS[] =
|
|||||||
factor * 1000000000
|
factor * 1000000000
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
const uint32_t fmt::internal::BasicData<T>::POWERS_OF_10_32[] = {
|
const uint32_t spdlog::details::fmt::internal::BasicData<T>::POWERS_OF_10_32[] = {
|
||||||
0, FMT_POWERS_OF_10(1)
|
0, FMT_POWERS_OF_10(1)
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
const uint64_t fmt::internal::BasicData<T>::POWERS_OF_10_64[] = {
|
const uint64_t spdlog::details::fmt::internal::BasicData<T>::POWERS_OF_10_64[] = {
|
||||||
0,
|
0,
|
||||||
FMT_POWERS_OF_10(1),
|
FMT_POWERS_OF_10(1),
|
||||||
FMT_POWERS_OF_10(ULongLong(1000000000)),
|
FMT_POWERS_OF_10(ULongLong(1000000000)),
|
||||||
@ -433,19 +436,19 @@ const uint64_t fmt::internal::BasicData<T>::POWERS_OF_10_64[] = {
|
|||||||
ULongLong(1000000000) * ULongLong(1000000000) * 10
|
ULongLong(1000000000) * ULongLong(1000000000) * 10
|
||||||
};
|
};
|
||||||
|
|
||||||
FMT_FUNC void fmt::internal::report_unknown_type(char code, const char *type) {
|
FMT_FUNC void spdlog::details::fmt::internal::report_unknown_type(char code, const char *type) {
|
||||||
if (std::isprint(static_cast<unsigned char>(code))) {
|
if (std::isprint(static_cast<unsigned char>(code))) {
|
||||||
FMT_THROW(fmt::FormatError(
|
FMT_THROW(spdlog::details::fmt::FormatError(
|
||||||
fmt::format("unknown format code '{}' for {}", code, type)));
|
spdlog::details::fmt::format("unknown format code '{}' for {}", code, type)));
|
||||||
}
|
}
|
||||||
FMT_THROW(fmt::FormatError(
|
FMT_THROW(spdlog::details::fmt::FormatError(
|
||||||
fmt::format("unknown format code '\\x{:02x}' for {}",
|
spdlog::details::fmt::format("unknown format code '\\x{:02x}' for {}",
|
||||||
static_cast<unsigned>(code), type)));
|
static_cast<unsigned>(code), type)));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
FMT_FUNC fmt::internal::UTF8ToUTF16::UTF8ToUTF16(fmt::StringRef s) {
|
FMT_FUNC spdlog::details::fmt::internal::UTF8ToUTF16::UTF8ToUTF16(spdlog::details::fmt::StringRef s) {
|
||||||
int length = MultiByteToWideChar(
|
int length = MultiByteToWideChar(
|
||||||
CP_UTF8, MB_ERR_INVALID_CHARS, s.c_str(), -1, 0, 0);
|
CP_UTF8, MB_ERR_INVALID_CHARS, s.c_str(), -1, 0, 0);
|
||||||
static const char ERROR[] = "cannot convert string from UTF-8 to UTF-16";
|
static const char ERROR[] = "cannot convert string from UTF-8 to UTF-16";
|
||||||
@ -458,14 +461,14 @@ FMT_FUNC fmt::internal::UTF8ToUTF16::UTF8ToUTF16(fmt::StringRef s) {
|
|||||||
FMT_THROW(WindowsError(GetLastError(), ERROR));
|
FMT_THROW(WindowsError(GetLastError(), ERROR));
|
||||||
}
|
}
|
||||||
|
|
||||||
FMT_FUNC fmt::internal::UTF16ToUTF8::UTF16ToUTF8(fmt::WStringRef s) {
|
FMT_FUNC spdlog::details::fmt::internal::UTF16ToUTF8::UTF16ToUTF8(spdlog::details::fmt::WStringRef s) {
|
||||||
if (int error_code = convert(s)) {
|
if (int error_code = convert(s)) {
|
||||||
FMT_THROW(WindowsError(error_code,
|
FMT_THROW(WindowsError(error_code,
|
||||||
"cannot convert string from UTF-16 to UTF-8"));
|
"cannot convert string from UTF-16 to UTF-8"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FMT_FUNC int fmt::internal::UTF16ToUTF8::convert(fmt::WStringRef s) {
|
FMT_FUNC int spdlog::details::fmt::internal::UTF16ToUTF8::convert(spdlog::details::fmt::WStringRef s) {
|
||||||
int length = WideCharToMultiByte(CP_UTF8, 0, s.c_str(), -1, 0, 0, 0, 0);
|
int length = WideCharToMultiByte(CP_UTF8, 0, s.c_str(), -1, 0, 0, 0, 0);
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
return GetLastError();
|
return GetLastError();
|
||||||
@ -477,7 +480,7 @@ FMT_FUNC int fmt::internal::UTF16ToUTF8::convert(fmt::WStringRef s) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
FMT_FUNC void fmt::WindowsError::init(
|
FMT_FUNC void spdlog::details::fmt::WindowsError::init(
|
||||||
int error_code, StringRef format_str, ArgList args) {
|
int error_code, StringRef format_str, ArgList args) {
|
||||||
error_code_ = error_code;
|
error_code_ = error_code;
|
||||||
MemoryWriter w;
|
MemoryWriter w;
|
||||||
@ -488,9 +491,9 @@ FMT_FUNC void fmt::WindowsError::init(
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FMT_FUNC void fmt::internal::format_system_error(
|
FMT_FUNC void spdlog::details::fmt::internal::format_system_error(
|
||||||
fmt::Writer &out, int error_code,
|
spdlog::details::fmt::Writer &out, int error_code,
|
||||||
fmt::StringRef message) FMT_NOEXCEPT(true) {
|
spdlog::details::fmt::StringRef message) FMT_NOEXCEPT(true) {
|
||||||
FMT_TRY {
|
FMT_TRY {
|
||||||
MemoryBuffer<char, INLINE_BUFFER_SIZE> buffer;
|
MemoryBuffer<char, INLINE_BUFFER_SIZE> buffer;
|
||||||
buffer.resize(INLINE_BUFFER_SIZE);
|
buffer.resize(INLINE_BUFFER_SIZE);
|
||||||
@ -510,9 +513,9 @@ FMT_FUNC void fmt::internal::format_system_error(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
FMT_FUNC void fmt::internal::format_windows_error(
|
FMT_FUNC void spdlog::details::fmt::internal::format_windows_error(
|
||||||
fmt::Writer &out, int error_code,
|
spdlog::details::fmt::Writer &out, int error_code,
|
||||||
fmt::StringRef message) FMT_NOEXCEPT(true) {
|
spdlog::details::fmt::StringRef message) FMT_NOEXCEPT(true) {
|
||||||
class String {
|
class String {
|
||||||
private:
|
private:
|
||||||
LPWSTR str_;
|
LPWSTR str_;
|
||||||
@ -548,17 +551,17 @@ FMT_FUNC void fmt::internal::format_windows_error(
|
|||||||
|
|
||||||
// An argument formatter.
|
// An argument formatter.
|
||||||
template <typename Char>
|
template <typename Char>
|
||||||
class fmt::internal::ArgFormatter :
|
class spdlog::details::fmt::internal::ArgFormatter :
|
||||||
public fmt::internal::ArgVisitor<fmt::internal::ArgFormatter<Char>, void> {
|
public spdlog::details::fmt::internal::ArgVisitor<spdlog::details::fmt::internal::ArgFormatter<Char>, void> {
|
||||||
private:
|
private:
|
||||||
fmt::BasicFormatter<Char> &formatter_;
|
spdlog::details::fmt::BasicFormatter<Char> &formatter_;
|
||||||
fmt::BasicWriter<Char> &writer_;
|
spdlog::details::fmt::BasicWriter<Char> &writer_;
|
||||||
fmt::FormatSpec &spec_;
|
spdlog::details::fmt::FormatSpec &spec_;
|
||||||
const Char *format_;
|
const Char *format_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ArgFormatter(
|
ArgFormatter(
|
||||||
fmt::BasicFormatter<Char> &f, fmt::FormatSpec &s, const Char *fmt)
|
spdlog::details::fmt::BasicFormatter<Char> &f, spdlog::details::fmt::FormatSpec &s, const Char *fmt)
|
||||||
: formatter_(f), writer_(f.writer()), spec_(s), format_(fmt) {}
|
: formatter_(f), writer_(f.writer()), spec_(s), format_(fmt) {}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -579,16 +582,16 @@ public:
|
|||||||
}
|
}
|
||||||
if (spec_.align_ == ALIGN_NUMERIC || spec_.flags_ != 0)
|
if (spec_.align_ == ALIGN_NUMERIC || spec_.flags_ != 0)
|
||||||
FMT_THROW(FormatError("invalid format specifier for char"));
|
FMT_THROW(FormatError("invalid format specifier for char"));
|
||||||
typedef typename fmt::BasicWriter<Char>::CharPtr CharPtr;
|
typedef typename spdlog::details::fmt::BasicWriter<Char>::CharPtr CharPtr;
|
||||||
CharPtr out = CharPtr();
|
CharPtr out = CharPtr();
|
||||||
if (spec_.width_ > 1) {
|
if (spec_.width_ > 1) {
|
||||||
Char fill = static_cast<Char>(spec_.fill());
|
Char fill = static_cast<Char>(spec_.fill());
|
||||||
out = writer_.grow_buffer(spec_.width_);
|
out = writer_.grow_buffer(spec_.width_);
|
||||||
if (spec_.align_ == fmt::ALIGN_RIGHT) {
|
if (spec_.align_ == spdlog::details::fmt::ALIGN_RIGHT) {
|
||||||
std::fill_n(out, spec_.width_ - 1, fill);
|
std::fill_n(out, spec_.width_ - 1, fill);
|
||||||
out += spec_.width_ - 1;
|
out += spec_.width_ - 1;
|
||||||
}
|
}
|
||||||
else if (spec_.align_ == fmt::ALIGN_CENTER) {
|
else if (spec_.align_ == spdlog::details::fmt::ALIGN_CENTER) {
|
||||||
out = writer_.fill_padding(out, spec_.width_, 1, fill);
|
out = writer_.fill_padding(out, spec_.width_, 1, fill);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -610,8 +613,8 @@ public:
|
|||||||
|
|
||||||
void visit_pointer(const void *value) {
|
void visit_pointer(const void *value) {
|
||||||
if (spec_.type_ && spec_.type_ != 'p')
|
if (spec_.type_ && spec_.type_ != 'p')
|
||||||
fmt::internal::report_unknown_type(spec_.type_, "pointer");
|
spdlog::details::fmt::internal::report_unknown_type(spec_.type_, "pointer");
|
||||||
spec_.flags_ = fmt::HASH_FLAG;
|
spec_.flags_ = spdlog::details::fmt::HASH_FLAG;
|
||||||
spec_.type_ = 'x';
|
spec_.type_ = 'x';
|
||||||
writer_.write_int(reinterpret_cast<uintptr_t>(value), spec_);
|
writer_.write_int(reinterpret_cast<uintptr_t>(value), spec_);
|
||||||
}
|
}
|
||||||
@ -623,7 +626,7 @@ public:
|
|||||||
|
|
||||||
template <typename Char>
|
template <typename Char>
|
||||||
template <typename StrChar>
|
template <typename StrChar>
|
||||||
FMT_FUNC void fmt::BasicWriter<Char>::write_str(
|
FMT_FUNC void spdlog::details::fmt::BasicWriter<Char>::write_str(
|
||||||
const Arg::StringValue<StrChar> &str, const FormatSpec &spec) {
|
const Arg::StringValue<StrChar> &str, const FormatSpec &spec) {
|
||||||
// Check if StrChar is convertible to Char.
|
// Check if StrChar is convertible to Char.
|
||||||
internal::CharTraits<Char>::convert(StrChar());
|
internal::CharTraits<Char>::convert(StrChar());
|
||||||
@ -641,7 +644,7 @@ FMT_FUNC void fmt::BasicWriter<Char>::write_str(
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Char>
|
template <typename Char>
|
||||||
inline Arg fmt::BasicFormatter<Char>::parse_arg_index(const Char *&s) {
|
inline Arg spdlog::details::fmt::BasicFormatter<Char>::parse_arg_index(const Char *&s) {
|
||||||
const char *error = 0;
|
const char *error = 0;
|
||||||
Arg arg = *s < '0' || *s > '9' ?
|
Arg arg = *s < '0' || *s > '9' ?
|
||||||
next_arg(error) : get_arg(parse_nonnegative_int(s), error);
|
next_arg(error) : get_arg(parse_nonnegative_int(s), error);
|
||||||
@ -652,7 +655,7 @@ inline Arg fmt::BasicFormatter<Char>::parse_arg_index(const Char *&s) {
|
|||||||
return arg;
|
return arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
FMT_FUNC Arg fmt::internal::FormatterBase::do_get_arg(
|
FMT_FUNC Arg spdlog::details::fmt::internal::FormatterBase::do_get_arg(
|
||||||
unsigned arg_index, const char *&error) {
|
unsigned arg_index, const char *&error) {
|
||||||
Arg arg = args_[arg_index];
|
Arg arg = args_[arg_index];
|
||||||
if (arg.type == Arg::NONE)
|
if (arg.type == Arg::NONE)
|
||||||
@ -660,14 +663,14 @@ FMT_FUNC Arg fmt::internal::FormatterBase::do_get_arg(
|
|||||||
return arg;
|
return arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Arg fmt::internal::FormatterBase::next_arg(const char *&error) {
|
inline Arg spdlog::details::fmt::internal::FormatterBase::next_arg(const char *&error) {
|
||||||
if (next_arg_index_ >= 0)
|
if (next_arg_index_ >= 0)
|
||||||
return do_get_arg(next_arg_index_++, error);
|
return do_get_arg(next_arg_index_++, error);
|
||||||
error = "cannot switch from manual to automatic argument indexing";
|
error = "cannot switch from manual to automatic argument indexing";
|
||||||
return Arg();
|
return Arg();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Arg fmt::internal::FormatterBase::get_arg(
|
inline Arg spdlog::details::fmt::internal::FormatterBase::get_arg(
|
||||||
unsigned arg_index, const char *&error) {
|
unsigned arg_index, const char *&error) {
|
||||||
if (next_arg_index_ <= 0) {
|
if (next_arg_index_ <= 0) {
|
||||||
next_arg_index_ = -1;
|
next_arg_index_ = -1;
|
||||||
@ -678,7 +681,7 @@ inline Arg fmt::internal::FormatterBase::get_arg(
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Char>
|
template <typename Char>
|
||||||
FMT_FUNC void fmt::internal::PrintfFormatter<Char>::parse_flags(
|
FMT_FUNC void spdlog::details::fmt::internal::PrintfFormatter<Char>::parse_flags(
|
||||||
FormatSpec &spec, const Char *&s) {
|
FormatSpec &spec, const Char *&s) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
switch (*s++) {
|
switch (*s++) {
|
||||||
@ -705,7 +708,7 @@ FMT_FUNC void fmt::internal::PrintfFormatter<Char>::parse_flags(
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Char>
|
template <typename Char>
|
||||||
FMT_FUNC Arg fmt::internal::PrintfFormatter<Char>::get_arg(
|
FMT_FUNC Arg spdlog::details::fmt::internal::PrintfFormatter<Char>::get_arg(
|
||||||
const Char *s, unsigned arg_index) {
|
const Char *s, unsigned arg_index) {
|
||||||
const char *error = 0;
|
const char *error = 0;
|
||||||
Arg arg = arg_index == UINT_MAX ?
|
Arg arg = arg_index == UINT_MAX ?
|
||||||
@ -716,7 +719,7 @@ FMT_FUNC Arg fmt::internal::PrintfFormatter<Char>::get_arg(
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Char>
|
template <typename Char>
|
||||||
FMT_FUNC unsigned fmt::internal::PrintfFormatter<Char>::parse_header(
|
FMT_FUNC unsigned spdlog::details::fmt::internal::PrintfFormatter<Char>::parse_header(
|
||||||
const Char *&s, FormatSpec &spec) {
|
const Char *&s, FormatSpec &spec) {
|
||||||
unsigned arg_index = UINT_MAX;
|
unsigned arg_index = UINT_MAX;
|
||||||
Char c = *s;
|
Char c = *s;
|
||||||
@ -752,7 +755,7 @@ FMT_FUNC unsigned fmt::internal::PrintfFormatter<Char>::parse_header(
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Char>
|
template <typename Char>
|
||||||
FMT_FUNC void fmt::internal::PrintfFormatter<Char>::format(
|
FMT_FUNC void spdlog::details::fmt::internal::PrintfFormatter<Char>::format(
|
||||||
BasicWriter<Char> &writer, BasicStringRef<Char> format,
|
BasicWriter<Char> &writer, BasicStringRef<Char> format,
|
||||||
const ArgList &args) {
|
const ArgList &args) {
|
||||||
const Char *start = format.c_str();
|
const Char *start = format.c_str();
|
||||||
@ -806,7 +809,7 @@ FMT_FUNC void fmt::internal::PrintfFormatter<Char>::format(
|
|||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
if (*s == 'l')
|
if (*s == 'l')
|
||||||
ArgConverter<fmt::LongLong>(arg, *++s).visit(arg);
|
ArgConverter<spdlog::details::fmt::LongLong>(arg, *++s).visit(arg);
|
||||||
else
|
else
|
||||||
ArgConverter<long>(arg, *s).visit(arg);
|
ArgConverter<long>(arg, *s).visit(arg);
|
||||||
break;
|
break;
|
||||||
@ -923,7 +926,7 @@ FMT_FUNC void fmt::internal::PrintfFormatter<Char>::format(
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Char>
|
template <typename Char>
|
||||||
FMT_FUNC const Char *fmt::BasicFormatter<Char>::format(
|
FMT_FUNC const Char *spdlog::details::fmt::BasicFormatter<Char>::format(
|
||||||
const Char *&format_str, const Arg &arg) {
|
const Char *&format_str, const Arg &arg) {
|
||||||
const Char *s = format_str;
|
const Char *s = format_str;
|
||||||
FormatSpec spec;
|
FormatSpec spec;
|
||||||
@ -1063,7 +1066,7 @@ FMT_FUNC const Char *fmt::BasicFormatter<Char>::format(
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Char>
|
template <typename Char>
|
||||||
FMT_FUNC void fmt::BasicFormatter<Char>::format(
|
FMT_FUNC void spdlog::details::fmt::BasicFormatter<Char>::format(
|
||||||
BasicStringRef<Char> format_str, const ArgList &args) {
|
BasicStringRef<Char> format_str, const ArgList &args) {
|
||||||
const Char *s = start_ = format_str.c_str();
|
const Char *s = start_ = format_str.c_str();
|
||||||
set_args(args);
|
set_args(args);
|
||||||
@ -1084,35 +1087,35 @@ FMT_FUNC void fmt::BasicFormatter<Char>::format(
|
|||||||
write(writer_, start_, s);
|
write(writer_, start_, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
FMT_FUNC void fmt::report_system_error(
|
FMT_FUNC void spdlog::details::fmt::report_system_error(
|
||||||
int error_code, fmt::StringRef message) FMT_NOEXCEPT(true) {
|
int error_code, spdlog::details::fmt::StringRef message) FMT_NOEXCEPT(true) {
|
||||||
report_error(internal::format_system_error, error_code, message);
|
report_error(internal::format_system_error, error_code, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
FMT_FUNC void fmt::report_windows_error(
|
FMT_FUNC void spdlog::details::fmt::report_windows_error(
|
||||||
int error_code, fmt::StringRef message) FMT_NOEXCEPT(true) {
|
int error_code, spdlog::details::fmt::StringRef message) FMT_NOEXCEPT(true) {
|
||||||
report_error(internal::format_windows_error, error_code, message);
|
report_error(internal::format_windows_error, error_code, message);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FMT_FUNC void fmt::print(std::FILE *f, StringRef format_str, ArgList args) {
|
FMT_FUNC void spdlog::details::fmt::print(std::FILE *f, StringRef format_str, ArgList args) {
|
||||||
MemoryWriter w;
|
MemoryWriter w;
|
||||||
w.write(format_str, args);
|
w.write(format_str, args);
|
||||||
std::fwrite(w.data(), 1, w.size(), f);
|
std::fwrite(w.data(), 1, w.size(), f);
|
||||||
}
|
}
|
||||||
|
|
||||||
FMT_FUNC void fmt::print(StringRef format_str, ArgList args) {
|
FMT_FUNC void spdlog::details::fmt::print(StringRef format_str, ArgList args) {
|
||||||
print(stdout, format_str, args);
|
print(stdout, format_str, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
FMT_FUNC void fmt::print(std::ostream &os, StringRef format_str, ArgList args) {
|
FMT_FUNC void spdlog::details::fmt::print(std::ostream &os, StringRef format_str, ArgList args) {
|
||||||
MemoryWriter w;
|
MemoryWriter w;
|
||||||
w.write(format_str, args);
|
w.write(format_str, args);
|
||||||
os.write(w.data(), w.size());
|
os.write(w.data(), w.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
FMT_FUNC void fmt::print_colored(Color c, StringRef format, ArgList args) {
|
FMT_FUNC void spdlog::details::fmt::print_colored(Color c, StringRef format, ArgList args) {
|
||||||
char escape[] = "\x1b[30m";
|
char escape[] = "\x1b[30m";
|
||||||
escape[3] = '0' + static_cast<char>(c);
|
escape[3] = '0' + static_cast<char>(c);
|
||||||
std::fputs(escape, stdout);
|
std::fputs(escape, stdout);
|
||||||
@ -1120,7 +1123,7 @@ FMT_FUNC void fmt::print_colored(Color c, StringRef format, ArgList args) {
|
|||||||
std::fputs(RESET_COLOR, stdout);
|
std::fputs(RESET_COLOR, stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
FMT_FUNC int fmt::fprintf(std::FILE *f, StringRef format, ArgList args) {
|
FMT_FUNC int spdlog::details::fmt::fprintf(std::FILE *f, StringRef format, ArgList args) {
|
||||||
MemoryWriter w;
|
MemoryWriter w;
|
||||||
printf(w, format, args);
|
printf(w, format, args);
|
||||||
std::size_t size = w.size();
|
std::size_t size = w.size();
|
||||||
@ -1129,40 +1132,40 @@ FMT_FUNC int fmt::fprintf(std::FILE *f, StringRef format, ArgList args) {
|
|||||||
|
|
||||||
// Explicit instantiations for char.
|
// Explicit instantiations for char.
|
||||||
|
|
||||||
template const char *fmt::BasicFormatter<char>::format(
|
template const char *spdlog::details::fmt::BasicFormatter<char>::format(
|
||||||
const char *&format_str, const fmt::internal::Arg &arg);
|
const char *&format_str, const spdlog::details::fmt::internal::Arg &arg);
|
||||||
|
|
||||||
template void fmt::BasicFormatter<char>::format(
|
template void spdlog::details::fmt::BasicFormatter<char>::format(
|
||||||
BasicStringRef<char> format, const ArgList &args);
|
BasicStringRef<char> format, const ArgList &args);
|
||||||
|
|
||||||
template void fmt::internal::PrintfFormatter<char>::format(
|
template void spdlog::details::fmt::internal::PrintfFormatter<char>::format(
|
||||||
BasicWriter<char> &writer, BasicStringRef<char> format, const ArgList &args);
|
BasicWriter<char> &writer, BasicStringRef<char> format, const ArgList &args);
|
||||||
|
|
||||||
template int fmt::internal::CharTraits<char>::format_float(
|
template int spdlog::details::fmt::internal::CharTraits<char>::format_float(
|
||||||
char *buffer, std::size_t size, const char *format,
|
char *buffer, std::size_t size, const char *format,
|
||||||
unsigned width, int precision, double value);
|
unsigned width, int precision, double value);
|
||||||
|
|
||||||
template int fmt::internal::CharTraits<char>::format_float(
|
template int spdlog::details::fmt::internal::CharTraits<char>::format_float(
|
||||||
char *buffer, std::size_t size, const char *format,
|
char *buffer, std::size_t size, const char *format,
|
||||||
unsigned width, int precision, long double value);
|
unsigned width, int precision, long double value);
|
||||||
|
|
||||||
// Explicit instantiations for wchar_t.
|
// Explicit instantiations for wchar_t.
|
||||||
|
|
||||||
template const wchar_t *fmt::BasicFormatter<wchar_t>::format(
|
template const wchar_t *spdlog::details::fmt::BasicFormatter<wchar_t>::format(
|
||||||
const wchar_t *&format_str, const fmt::internal::Arg &arg);
|
const wchar_t *&format_str, const spdlog::details::fmt::internal::Arg &arg);
|
||||||
|
|
||||||
template void fmt::BasicFormatter<wchar_t>::format(
|
template void spdlog::details::fmt::BasicFormatter<wchar_t>::format(
|
||||||
BasicStringRef<wchar_t> format, const ArgList &args);
|
BasicStringRef<wchar_t> format, const ArgList &args);
|
||||||
|
|
||||||
template void fmt::internal::PrintfFormatter<wchar_t>::format(
|
template void spdlog::details::fmt::internal::PrintfFormatter<wchar_t>::format(
|
||||||
BasicWriter<wchar_t> &writer, BasicStringRef<wchar_t> format,
|
BasicWriter<wchar_t> &writer, BasicStringRef<wchar_t> format,
|
||||||
const ArgList &args);
|
const ArgList &args);
|
||||||
|
|
||||||
template int fmt::internal::CharTraits<wchar_t>::format_float(
|
template int spdlog::details::fmt::internal::CharTraits<wchar_t>::format_float(
|
||||||
wchar_t *buffer, std::size_t size, const wchar_t *format,
|
wchar_t *buffer, std::size_t size, const wchar_t *format,
|
||||||
unsigned width, int precision, double value);
|
unsigned width, int precision, double value);
|
||||||
|
|
||||||
template int fmt::internal::CharTraits<wchar_t>::format_float(
|
template int spdlog::details::fmt::internal::CharTraits<wchar_t>::format_float(
|
||||||
wchar_t *buffer, std::size_t size, const wchar_t *format,
|
wchar_t *buffer, std::size_t size, const wchar_t *format,
|
||||||
unsigned width, int precision, long double value);
|
unsigned width, int precision, long double value);
|
||||||
|
|
||||||
|
@ -115,7 +115,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#define FMT_DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
#define FMT_DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
||||||
TypeName(const TypeName&); \
|
TypeName(const TypeName&); \
|
||||||
void operator=(const TypeName&)
|
void operator=(const TypeName&)
|
||||||
|
namespace spdlog {
|
||||||
|
namespace details {
|
||||||
namespace fmt
|
namespace fmt
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -1053,7 +1054,7 @@ public:
|
|||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
assert(false);
|
assert(false);
|
||||||
// Fall through.
|
// Fall through.
|
||||||
case Arg::INT:
|
case Arg::INT:
|
||||||
return FMT_DISPATCH(visit_int(arg.int_value));
|
return FMT_DISPATCH(visit_int(arg.int_value));
|
||||||
case Arg::UINT:
|
case Arg::UINT:
|
||||||
@ -2222,7 +2223,7 @@ void BasicWriter<Char>::write_double(
|
|||||||
// MSVC's printf doesn't support 'F'.
|
// MSVC's printf doesn't support 'F'.
|
||||||
type = 'f';
|
type = 'f';
|
||||||
#endif
|
#endif
|
||||||
// Fall through.
|
// Fall through.
|
||||||
case 'E':
|
case 'E':
|
||||||
case 'G':
|
case 'G':
|
||||||
case 'A':
|
case 'A':
|
||||||
@ -2739,7 +2740,9 @@ inline void format_decimal(char *&buffer, T value)
|
|||||||
internal::format_decimal(buffer, abs_value, num_digits);
|
internal::format_decimal(buffer, abs_value, num_digits);
|
||||||
buffer += num_digits;
|
buffer += num_digits;
|
||||||
}
|
}
|
||||||
}
|
} // ns fmt
|
||||||
|
} // ns deatils
|
||||||
|
} // ns spdlog
|
||||||
|
|
||||||
#if FMT_GCC_VERSION
|
#if FMT_GCC_VERSION
|
||||||
// Use the system_header pragma to suppress warnings about variadic macros
|
// Use the system_header pragma to suppress warnings about variadic macros
|
||||||
@ -2846,6 +2849,8 @@ fmt::print(format, args...);
|
|||||||
#define FMT_VARIADIC_W(ReturnType, func, ...) \
|
#define FMT_VARIADIC_W(ReturnType, func, ...) \
|
||||||
FMT_VARIADIC_(wchar_t, ReturnType, func, return func, __VA_ARGS__)
|
FMT_VARIADIC_(wchar_t, ReturnType, func, return func, __VA_ARGS__)
|
||||||
|
|
||||||
|
namespace spdlog {
|
||||||
|
namespace details {
|
||||||
namespace fmt
|
namespace fmt
|
||||||
{
|
{
|
||||||
FMT_VARIADIC(std::string, format, StringRef)
|
FMT_VARIADIC(std::string, format, StringRef)
|
||||||
@ -2858,6 +2863,8 @@ FMT_VARIADIC(std::string, sprintf, StringRef)
|
|||||||
FMT_VARIADIC(int, printf, StringRef)
|
FMT_VARIADIC(int, printf, StringRef)
|
||||||
FMT_VARIADIC(int, fprintf, std::FILE *, StringRef)
|
FMT_VARIADIC(int, fprintf, std::FILE *, StringRef)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Restore warnings.
|
// Restore warnings.
|
||||||
#if FMT_GCC_VERSION >= 406
|
#if FMT_GCC_VERSION >= 406
|
||||||
|
@ -458,7 +458,7 @@ inline void spdlog::pattern_formatter::handle_flag(char flag)
|
|||||||
{
|
{
|
||||||
switch (flag)
|
switch (flag)
|
||||||
{
|
{
|
||||||
// logger name
|
// logger name
|
||||||
case 'n':
|
case 'n':
|
||||||
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::name_formatter()));
|
_formatters.push_back(std::unique_ptr<details::flag_formatter>(new details::name_formatter()));
|
||||||
break;
|
break;
|
||||||
@ -582,8 +582,8 @@ inline void spdlog::pattern_formatter::format(details::log_msg& msg)
|
|||||||
//write eol
|
//write eol
|
||||||
msg.formatted << details::os::eol();
|
msg.formatted << details::os::eol();
|
||||||
}
|
}
|
||||||
catch(const fmt::FormatError& e)
|
catch(const details::fmt::FormatError& e)
|
||||||
{
|
{
|
||||||
throw spdlog_ex(fmt::format("formatting error while processing format string: {}", e.what()));
|
throw spdlog_ex(details::fmt::format("formatting error while processing format string: {}", e.what()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
static std::string calc_filename(const std::string& filename, std::size_t index, const std::string& extension)
|
static std::string calc_filename(const std::string& filename, std::size_t index, const std::string& extension)
|
||||||
{
|
{
|
||||||
fmt::MemoryWriter w;
|
details::fmt::MemoryWriter w;
|
||||||
if (index)
|
if (index)
|
||||||
w.write("{}.{}.{}", filename, index, extension);
|
w.write("{}.{}.{}", filename, index, extension);
|
||||||
else
|
else
|
||||||
@ -196,7 +196,7 @@ private:
|
|||||||
static std::string calc_filename(const std::string& basename, const std::string& extension)
|
static std::string calc_filename(const std::string& basename, const std::string& extension)
|
||||||
{
|
{
|
||||||
std::tm tm = spdlog::details::os::localtime();
|
std::tm tm = spdlog::details::os::localtime();
|
||||||
fmt::MemoryWriter w;
|
details::fmt::MemoryWriter w;
|
||||||
w.write("{}.{:04d}-{:02d}-{:02d}.{}", basename, tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, extension);
|
w.write("{}.{:04d}-{:02d}-{:02d}.{}", basename, tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, extension);
|
||||||
return w.str();
|
return w.str();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user