Log to user-defined stream (instead of std::cerr)
gggin opened this issue · 8 comments
usually logging library support android.
This is not a logging library.
What exactly do you mean by "android support"?
if you made a choice for no android support , you should provider a interface for replace std::err << to something else to support android output interface so I can write my own __android_log_print
wrapper. Without change you original source code.
something like this:
https://stackoverflow.com/questions/12152555/how-to-print-log-in-android-c-file
@xorz57 cpp library should be run on any platform that support c++, If cannot or featureless, maybe provide something extension to extend the library.I already change std::err to my own logging library for usage. It's easy for me, maybe not for others.
@gggin If I understand you correctly, you would like to use the core-functionality of this library without having to rely on std::cerr
to be availble? Sounds like a reasonable request for me.
Yes. @sharkdp maybe Template specialization, or a setter for a lambda or otherthings。
FWIW, the similar libs in Go and Python also logs to /tmp/q
so it's easier to inspect on complex systems. It's useful when the program
- logs to some file and does not have stderr, or
- already have too much logs in stderr
It's more like a choice about how quick-and-dirty dbg-macro would like to be though.
As for /tmp/q
, I think that would work fine as long as you are running just a single process that writes to /tmp/q
. As soon as multiple programs are running ("complex systems", as stated in your comment), that would not work at all. So we would probably have to add the PID and write to /tmp/q.$PID
or similar. That immediately makes this less useful.
As for writing to something else then std::cerr
: I would like to avoid adding more configuration options for now. I'm trying to design this library such that users only #include <dbg.h>
and then immediately start putting dbg(…)
in their code. Without any other compile- or runtime configuration.