17 #ifndef MASTODONPP_LOG_HPP
18 #define MASTODONPP_LOG_HPP
21 #include <string_view>
27 using std::string_view;
30 constexpr
auto shorten_filename(
const string_view &filename)
32 for (
const string_view &dir : {
"/src/",
"/include/"})
34 const auto pos{filename.rfind(dir)};
35 if (pos != string_view::npos)
37 return filename.substr(pos + dir.size());
43 #define commonlog cerr << '[' << shorten_filename(__FILE__) \
44 << ':' << __LINE__ << ']'
46 #define debuglog commonlog << " DEBUG: "
48 #define debuglog false && cerr
50 #define errorlog commonlog << " ERROR: "
54 #endif // MASTODONPP_LOG_HPP