10#if !defined(USERVER_LOG_PREFIX_PATH_BASE) &&
11 !defined(USERVER_LOG_SOURCE_PATH_BASE) &&
12 !defined(USERVER_LOG_BUILD_PATH_BASE)
20#define USERVER_FILEPATH
21 std::string_view { __builtin_FILE() }
25namespace logging::impl {
29#define USERVER_LOG_FILEPATH_STRINGIZE_AUX(X) #X
31#define USERVER_LOG_FILEPATH_STRINGIZE(X) USERVER_LOG_FILEPATH_STRINGIZE_AUX(X)
34static constexpr std::size_t PathBaseSize(std::string_view path)
noexcept {
35 constexpr std::string_view kSourcePathPrefixes[] = {
36#ifdef USERVER_LOG_PREFIX_PATH_BASE
37 USERVER_LOG_FILEPATH_STRINGIZE(USERVER_LOG_PREFIX_PATH_BASE),
39#ifdef USERVER_LOG_SOURCE_PATH_BASE
40 USERVER_LOG_FILEPATH_STRINGIZE(USERVER_LOG_SOURCE_PATH_BASE),
42#ifdef USERVER_LOG_BUILD_PATH_BASE
43 USERVER_LOG_FILEPATH_STRINGIZE(USERVER_LOG_BUILD_PATH_BASE),
47 for (
const std::string_view base : kSourcePathPrefixes) {
48 if (path.substr(0, base.size()) == base) {
49 std::size_t base_size = path.find_first_not_of(
'/', base.size());
50 if (base_size == std::string_view::npos) {
51 base_size = path.size();
61static constexpr std::string_view CutFilePath(
const char* path)
noexcept {
62 const std::string_view path_view = path;
63 return path_view.substr(impl::PathBaseSize(path_view));
66#undef USERVER_LOG_FILEPATH_STRINGIZE
67#undef USERVER_LOG_FILEPATH_STRINGIZE_AUX
72#define USERVER_FILEPATH
73 USERVER_NAMESPACE::logging::impl::CutFilePath(__builtin_FILE())