strip caffe's logging message from my own c++ program -
i making own c++ classification program using caffe library. want hide logging messages during caffe's model initialization step.
according disable glog's "log(info)" logging, disable of logs setting environment variable
glog_minloglevel=2
from command line.
but, want remove logs executable itself, user can not turn on logs resetting glog_minloglevel value.
i find way strip glog's logging message on compile time http://rpg.ifi.uzh.ch/docs/glog.html. says can remove logs this:
> #define google_strip_log 1 // must go before #include! > #include <glog/logging.h>
since application uses caffe's c++ library, needed rebuild caffe library adding following option add_definitions(-dgoogle_strip_log=2)
caffe's cmakelists.txt. compile successful, when ran application new caffe library, stops segmentation fault error during model initialization step. bit more detailed error message running gdb this:
program received signal sigsegv, segmentation fault. __memcpy_sse2_unaligned () @ ../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.s:153 153 ../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.s: no such file or directory
when roll original caffe library without add_definitions(-dgoogle_strip_log=2)
in caffe's cmakelists.txt, application runs fine.
can give me hint solving problem?
thank in advance.
consider google::logtostderr() described as: "make log messages go stderr." (see glog/logging.h).
so, whatever it's doing give clue how might disable logging files. turns out implementation simply:
setstderrlogging(0); // "also" logged stderr ( int = 0; < num_severities; ++i ) { setlogdestination(i, ""); // "" turns off logging logfile }
so, disable logging files, need setlogdestination() "", severities.
you'll want disable logging stderr (it seems default glog_error). can accomplished addition of:
google::setstderrlogging( google::num_severities );
btw, rationale doing want redirect glog messages different logging framework in use app. i've found can accomplish additionally calling google::addlogsink(), own sink.
Comments
Post a Comment