Closed Qix- closed 5 years ago
You can accomplish this by making you own macro:
void my_perror(const char* file, unsigned line)
{
...
loguru::log(loguru::Verbosity_INFO, file, line, "some text");
}
#define MY_PERROR my_perror(__FILE__, __LINE__)
Sometimes a macro isn't possible, though. Being able to use a stream modifier would be really convenient.
I agree it would be nice. The problem is that would require getting the file/line from the stacktrace which is slow, unreliable and not always available.
Not getting the file, but instead just knocking one frame off the call to backtrack (since it gives you a list of void pointers).
loguru::stacktrace
takes a skip
argument that does just this.
Ah I see, you're not getting the backtrace for each logging invocation. Not sure why I had that in my head.
Thanks :)
It'd be great if I could do something like the following:
The use-case here is that I often write
perror()
-like functions that aren't useful whereLOG_S
is being used but are instead important where the wrapper was called.