mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-27 03:00:46 +08:00
Merge pull request #2381 from Esri/john4744/android_fmt_compile_time_check
Add FMT_STRING to allow compilation with FMT_ENFORCE_COMPILE_STRING
This commit is contained in:
commit
d546201f12
@ -46,11 +46,13 @@
|
|||||||
|
|
||||||
#if !defined(SPDLOG_USE_STD_FORMAT) && FMT_VERSION >= 80000 // backward compatibility with fmt versions older than 8
|
#if !defined(SPDLOG_USE_STD_FORMAT) && FMT_VERSION >= 80000 // backward compatibility with fmt versions older than 8
|
||||||
# define SPDLOG_FMT_RUNTIME(format_string) fmt::runtime(format_string)
|
# define SPDLOG_FMT_RUNTIME(format_string) fmt::runtime(format_string)
|
||||||
|
# define SPDLOG_FMT_STRING(format_string) FMT_STRING(format_string)
|
||||||
# if defined(SPDLOG_WCHAR_FILENAMES) || defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT)
|
# if defined(SPDLOG_WCHAR_FILENAMES) || defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT)
|
||||||
# include <spdlog/fmt/xchar.h>
|
# include <spdlog/fmt/xchar.h>
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
# define SPDLOG_FMT_RUNTIME(format_string) format_string
|
# define SPDLOG_FMT_RUNTIME(format_string) format_string
|
||||||
|
# define SPDLOG_FMT_STRING(format_string) format_string
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// visual studio up to 2013 does not support noexcept nor constexpr
|
// visual studio up to 2013 does not support noexcept nor constexpr
|
||||||
@ -308,7 +310,7 @@ struct file_event_handlers
|
|||||||
{
|
{
|
||||||
file_event_handlers()
|
file_event_handlers()
|
||||||
: before_open(nullptr)
|
: before_open(nullptr)
|
||||||
, after_open (nullptr)
|
, after_open(nullptr)
|
||||||
, before_close(nullptr)
|
, before_close(nullptr)
|
||||||
, after_close(nullptr)
|
, after_close(nullptr)
|
||||||
{}
|
{}
|
||||||
|
@ -107,7 +107,7 @@ inline void pad2(int n, memory_buf_t &dest)
|
|||||||
}
|
}
|
||||||
else // unlikely, but just in case, let fmt deal with it
|
else // unlikely, but just in case, let fmt deal with it
|
||||||
{
|
{
|
||||||
fmt_lib::format_to(std::back_inserter(dest), "{:02}", n);
|
fmt_lib::format_to(std::back_inserter(dest), SPDLOG_FMT_STRING("{:02}"), n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,7 +241,7 @@ struct formatter<spdlog::details::dump_info<T>, char>
|
|||||||
|
|
||||||
if (put_positions)
|
if (put_positions)
|
||||||
{
|
{
|
||||||
spdlog::fmt_lib::format_to(inserter, "{:04X}: ", pos);
|
spdlog::fmt_lib::format_to(inserter, SPDLOG_FMT_STRING("{:04X}: "), pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
{ \
|
{ \
|
||||||
if (location.filename) \
|
if (location.filename) \
|
||||||
{ \
|
{ \
|
||||||
err_handler_(fmt_lib::format("{} [{}({})]", ex.what(), location.filename, location.line)); \
|
err_handler_(fmt_lib::format(SPDLOG_FMT_STRING("{} [{}({})]"), ex.what(), location.filename, location.line)); \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
{ \
|
{ \
|
||||||
|
@ -32,8 +32,8 @@ struct daily_filename_calculator
|
|||||||
{
|
{
|
||||||
filename_t basename, ext;
|
filename_t basename, ext;
|
||||||
std::tie(basename, ext) = details::file_helper::split_by_extension(filename);
|
std::tie(basename, ext) = details::file_helper::split_by_extension(filename);
|
||||||
return fmt_lib::format(
|
return fmt_lib::format(SPDLOG_FMT_STRING(SPDLOG_FILENAME_T("{}_{:04d}-{:02d}-{:02d}{}")), basename, now_tm.tm_year + 1900,
|
||||||
SPDLOG_FILENAME_T("{}_{:04d}-{:02d}-{:02d}{}"), basename, now_tm.tm_year + 1900, now_tm.tm_mon + 1, now_tm.tm_mday, ext);
|
now_tm.tm_mon + 1, now_tm.tm_mday, ext);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ struct daily_filename_format_calculator
|
|||||||
return buf;
|
return buf;
|
||||||
#else
|
#else
|
||||||
// generate fmt datetime format string, e.g. {:%Y-%m-%d}.
|
// generate fmt datetime format string, e.g. {:%Y-%m-%d}.
|
||||||
filename_t fmt_filename = fmt::format(SPDLOG_FILENAME_T("{{:{}}}"), filename);
|
filename_t fmt_filename = fmt::format(SPDLOG_FMT_STRING(SPDLOG_FILENAME_T("{{:{}}}")), filename);
|
||||||
# if defined(_MSC_VER) && defined(SPDLOG_WCHAR_FILENAMES) // for some reason msvc doesn't allow fmt::runtime(..) with wchar here
|
# if defined(_MSC_VER) && defined(SPDLOG_WCHAR_FILENAMES) // for some reason msvc doesn't allow fmt::runtime(..) with wchar here
|
||||||
return fmt::format(fmt_filename, now_tm);
|
return fmt::format(fmt_filename, now_tm);
|
||||||
# else
|
# else
|
||||||
|
Loading…
Reference in New Issue
Block a user