10#if !defined(USERVER_LOG_PREFIX_PATH_BASE) && !defined(USERVER_LOG_SOURCE_PATH_BASE) &&
11 !defined(USERVER_LOG_BUILD_PATH_BASE)
19#define USERVER_FILEPATH
20 std::string_view { __builtin_FILE() }
24namespace logging::impl {
28#define USERVER_LOG_FILEPATH_STRINGIZE_AUX(X) #X
30#define USERVER_LOG_FILEPATH_STRINGIZE(X) USERVER_LOG_FILEPATH_STRINGIZE_AUX(X)
33static constexpr std::size_t PathBaseSize(std::string_view path)
noexcept {
34 constexpr std::string_view kSourcePathPrefixes[] = {
35#ifdef USERVER_LOG_PREFIX_PATH_BASE
36 USERVER_LOG_FILEPATH_STRINGIZE(USERVER_LOG_PREFIX_PATH_BASE),
38#ifdef USERVER_LOG_SOURCE_PATH_BASE
39 USERVER_LOG_FILEPATH_STRINGIZE(USERVER_LOG_SOURCE_PATH_BASE),
41#ifdef USERVER_LOG_BUILD_PATH_BASE
42 USERVER_LOG_FILEPATH_STRINGIZE(USERVER_LOG_BUILD_PATH_BASE),
46 for (
const std::string_view base : kSourcePathPrefixes) {
47 if (path.substr(0, base.size()) == base) {
48 std::size_t base_size = path.find_first_not_of(
'/', base.size());
49 if (base_size == std::string_view::npos) {
50 base_size = path.size();
60static constexpr std::string_view CutFilePath(
const char* path)
noexcept {
61 const std::string_view path_view = path;
62 return path_view.substr(impl::PathBaseSize(path_view));
65#undef USERVER_LOG_FILEPATH_STRINGIZE
66#undef USERVER_LOG_FILEPATH_STRINGIZE_AUX
71#define USERVER_FILEPATH USERVER_NAMESPACE::logging::impl::CutFilePath(__builtin_FILE())