Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "InitGoogleLogging" do?

I've been modifying an example C++ program from the Caffe deep learning library and I noticed this code on line 234 that doesn't appear to be referenced again.

::google::InitGoogleLogging(argv[0]);

The argument provided is a prototxt file which defines the parameters of the deep learning model I'm calling. The thing that is confusing me is where the results from this line go? I know they end up being used in the program because if I make a mistake in the prototxt file then the program will crash. However I'm struggling to see how the data is passed to the class performing the classification tasks.

like image 782
Jack Simpson Avatar asked Sep 02 '15 01:09

Jack Simpson


People also ask

Where does Glog write to?

Unless otherwise specified, glog writes to the filename "/tmp/<program name>. <hostname>. <user name>. log.

Is Glog thread safe?

Thread safe useThe default use of goby::glog is not thread safe. To enable thread-safe access (uses a mutex lock/unlock for each call from goby::util::FlexOstream::is to std::endl or std::flush), set (before any concurrent access): goby::glog.


1 Answers

First of all, argv[0] is not the first argument you pass to your executable, but rather the executable name. So you are passing to ::google::InitGoogleLogging the executable name and not the prototxt file.
'glog' module (google logging) is using this name to decorate the log entries it outputs.

Second, caffe is using google logging (aka 'glog') as its logging module, and hence this module must be initialized once when running caffe. This is why you have this

::google::InitGoogleLogging(argv[0]);

in your code.

like image 187
Shai Avatar answered Sep 20 '22 18:09

Shai