mirror of
https://github.com/gabime/spdlog.git
synced 2025-01-14 01:32:07 +08:00
Clean prev source_loc impl leftovers
This commit is contained in:
parent
c7fc302710
commit
6ea6b065ba
@ -202,29 +202,8 @@ private:
|
||||
};
|
||||
|
||||
[[noreturn]] SPDLOG_API void throw_spdlog_ex(const std::string &msg, int last_errno);
|
||||
|
||||
[[noreturn]] SPDLOG_API void throw_spdlog_ex(std::string msg);
|
||||
|
||||
// trick to capture format string and caller's source location with variadic template.
|
||||
// see logger::info() etc. to understand how it's used.
|
||||
struct loc_with_fmt {
|
||||
source_loc loc;
|
||||
string_view_t fmt_string;
|
||||
|
||||
template <typename S, typename = is_convertible_to_sv<S>>
|
||||
constexpr loc_with_fmt(S fmt_str, source_loc loc = source_loc::current()) noexcept
|
||||
: loc(loc),
|
||||
fmt_string(fmt_str) {}
|
||||
|
||||
#ifndef SPDLOG_USE_STD_FORMAT
|
||||
|
||||
constexpr loc_with_fmt(fmt::runtime_format_string<char> fmt_str, source_loc loc = source_loc::current()) noexcept
|
||||
: loc(loc),
|
||||
fmt_string(fmt_str.str) {}
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
struct file_event_handlers {
|
||||
file_event_handlers()
|
||||
: before_open(nullptr),
|
||||
|
@ -26,20 +26,6 @@ struct source_loc {
|
||||
short_filename{basename(filename_in)},
|
||||
line{line_in},
|
||||
funcname{funcname_in} {}
|
||||
|
||||
#ifdef SPDLOG_HAVE_STD_SOURCE_LOCATION
|
||||
static constexpr source_loc current(const std::source_location source_location = std::source_location::current()) {
|
||||
return source_loc{source_location.file_name(), source_location.line(), source_location.function_name()};
|
||||
}
|
||||
#elif defined(SPDLOG_HAVE_EXPERIMENTAL_SOURCE_LOCATION)
|
||||
static constexpr source_loc current(
|
||||
const std::experimental::source_location source_location = std::experimental::source_location::current()) {
|
||||
return source_loc{source_location.file_name(), source_location.line(), source_location.function_name()};
|
||||
}
|
||||
#else // no source location support
|
||||
static constexpr source_loc current() { return source_loc{}; }
|
||||
#endif
|
||||
|
||||
[[nodiscard]] constexpr bool empty() const noexcept { return line == 0 || filename == nullptr || short_filename == nullptr; }
|
||||
|
||||
const char *filename{nullptr};
|
||||
@ -64,4 +50,4 @@ struct source_loc {
|
||||
return file;
|
||||
}
|
||||
};
|
||||
} // namespace spdlog
|
||||
} // namespace spdlog
|
||||
|
@ -19,6 +19,3 @@ TEST_CASE("test_source_location", "[source_location]") {
|
||||
REQUIRE(test_sink->lines().size() == 2);
|
||||
REQUIRE(test_sink->lines()[1] == "test_source_location.cpp:18 Hello");
|
||||
}
|
||||
|
||||
|
||||
//REQUIRE(oss.str() == std::string("test_source_location.cpp:20 Hello source location") + default_eol);
|
||||
|
Loading…
Reference in New Issue
Block a user