summaryrefslogtreecommitdiffstats
path: root/src/log.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/log.hpp')
-rw-r--r--src/log.hpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/log.hpp b/src/log.hpp
index 5bdcc96..43d4fc4 100644
--- a/src/log.hpp
+++ b/src/log.hpp
@@ -18,14 +18,30 @@
#define MASTODONPP_LOG_HPP
#include <iostream>
+#include <string_view>
namespace mastodonpp
{
using std::cerr;
+using std::string_view;
+
+constexpr auto shorten_filename(const string_view &filename)
+{
+ for (const string_view &dir : {"/src/", "/include/"})
+ {
+ auto pos{filename.rfind("/src/")};
+ if (pos != string_view::npos)
+ {
+ return filename.substr(pos + dir.size());
+ }
+ }
+ return filename;
+}
#ifndef NDEBUG
- #define debuglog cerr << "[" << __func__ << "():" << __LINE__ << "] DEBUG: "
+#define debuglog cerr << "[" << shorten_filename(__FILE__) \
+ << ':' << __LINE__ << "] DEBUG: "
#else
#define debuglog false && cerr
#endif