Show filename in debuglog instead of function.
This commit is contained in:
parent
b8802d3674
commit
b93fe57cae
18
src/log.hpp
18
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user