I am now calling a C++ library in Python with the help of CFFI. This C++ library uses Google Logging Library for logging message. I know that when I set up a C++ application that calls the library, I can easily control where the log file is located:
#include <glog/logging.h>
int main(int argc, char* argv[]) {
// Initialize Google's logging library.
google::InitGoogleLogging(argv[0]);
// ...
LOG(INFO) << "Found " << num_cookies << " cookies";
}
However, now I am calling it from the Python codes. Then my question is how can I set up the log file so that the log information in the C++ library can be written to the defined log file. By the way, I have the source code of the C++ library, and I can compile it myself.
According to the docs, setting environment variable GLOG_log_dir
should work:
GLOG_log_dir='/my/log/dir/' python my_code.py
According to the code, setting environment variable GOOGLE_LOG_DIR
may also work.