Is there a “built-in way” for registering everything with glitches until the program crashes?

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; 
+4
source share
1 answer

I use gflags with glog, and if you run --help, then the logbuflevel option may be what you are looking for.

  -logbuflevel (Buffer log messages logged at this level or lower (-1 means don't buffer; 0 means buffer INFO only; ...)) type: int32 default: 0 
+2
source

All Articles