aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/misc/source_location.cpp
diff options
context:
space:
mode:
authordgolear <dgolear@yandex-team.com>2024-05-21 01:03:40 +0300
committerdgolear <dgolear@yandex-team.com>2024-05-21 01:15:41 +0300
commita92a0d80c339ed6f70624dffa79288e61b72e941 (patch)
tree14ae8539e97846150a92530242efeb4b5b5fc08e /library/cpp/yt/misc/source_location.cpp
parent52107f6c22b7a6a09f394b920b18b6bae386ceb7 (diff)
downloadydb-a92a0d80c339ed6f70624dffa79288e61b72e941.tar.gz
YT: Add FormatValue for std::source_location
YTORM-1057 0aa4ceb80d984a15c92a69f242ecf517b3c7a07c
Diffstat (limited to 'library/cpp/yt/misc/source_location.cpp')
-rw-r--r--library/cpp/yt/misc/source_location.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/library/cpp/yt/misc/source_location.cpp b/library/cpp/yt/misc/source_location.cpp
index 8d22d43636..3fe45e23a7 100644
--- a/library/cpp/yt/misc/source_location.cpp
+++ b/library/cpp/yt/misc/source_location.cpp
@@ -1,11 +1,37 @@
#include "source_location.h"
+#include <library/cpp/yt/string/format.h>
+
#include <string.h>
namespace NYT {
////////////////////////////////////////////////////////////////////////////////
+#ifdef __cpp_lib_source_location
+
+void FormatValue(TStringBuilderBase* builder, const std::source_location& location, TStringBuf /*format*/)
+{
+ if (location.file_name() != nullptr) {
+ builder->AppendFormat(
+ "%v:%v:%v",
+ location.file_name(),
+ location.line(),
+ location.column());
+ } else {
+ builder->AppendString("<unknown>");
+ }
+}
+
+TString ToString(const std::source_location& location)
+{
+ return ToStringViaBuilder(location);
+}
+
+#endif // __cpp_lib_source_location
+
+////////////////////////////////////////////////////////////////////////////////
+
const char* TSourceLocation::GetFileName() const
{
return FileName_;