I am interested in using some protocols to help me detect potential problems in my code and find out where my program crashed. My problem is that the lib I used (google glog) does not register the material if it occurs immediately before the program crashes. So I tried to do something like this (this is a template for 3 arguments):
mutex logMtx; template<class T, class U, class V> void mutexLOG_INFO(T t, U u, V v) { stringstream ss; ss<<t; ss<<u; ss<<v; LOG(INFO)<<ss.str(); mutex::scoped_lock sl(logMtx); google::FlushLogFiles(0); }
This works AFAIK (from my testing), but as you can see, it is not very nice, because I need to execute my own function for each level (INFO, WARNING ..) and for each number of parameters. I also hate reinventing the wheel.
So, is there a way to tell how glog is reset every time after LOG?
PS I know that this is g-log, not g-db (oops, name taken :), but I prefer to be able to print my STL data well, I use gdb only to find where something died.
EDIT: SO is proving again that this is a great source of information:
#include <glog/logging.h> #include <**gflags**/gflags.h> ... FLAGS_logbuflevel=-1;
source share