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());
44 #define commonlog cerr << '[' << shorten_filename(__FILE__) \
45 << ':' << __LINE__ << ']'
48 #define debuglog commonlog << " DEBUG: "
50 #define debuglog false && cerr
53 #define errorlog commonlog << " ERROR: "
57 #endif // MASTODONPP_LOG_HPP