-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How does bazel use WITH_CUSTOM_PREFIX
flag?
#675
Comments
|
When I defined #define GLOG_CUSTOM_PREFIX_SUPPORT
#include <iostream>
#include <iomanip>
#include <glog/logging.h>
using std::setw;
using std::setfill;
/* This function writes a prefix that matches glog's default format.
* (The third parameter can be used to receive user-supplied data, and is
* NULL by default.)
*/
void CustomPrefix(std::ostream &s, const LogMessageInfo &l, void*) {
s << l.severity[0]
<< setw(4) << 1900 + l.time.year()
<< setw(2) << 1 + l.time.month()
<< setw(2) << l.time.day()
<< ' '
<< setw(2) << l.time.hour() << ':'
<< setw(2) << l.time.min() << ':'
<< setw(2) << l.time.sec() << "."
<< setw(6) << l.time.usec()
<< ' '
<< setfill(' ') << setw(5)
<< l.thread_id << setfill('0')
<< ' '
<< l.filename << ':' << l.line_number << "]";
}
int main(int argc, char* argv[]) {
// FLAGS_log_dir = "./log";
google::InitGoogleLogging(argv[0], &CustomPrefix);
FLAGS_logtostderr = 1;
int num_cookies = 10;
LOG_IF(INFO, num_cookies > 10) << "Got lots of cookies";
for (int i = 0; i < 30; i++) {
LOG_EVERY_N(INFO, 10) << "Got the " << google::COUNTER << "th cookie";
}
DLOG(INFO) << "Found cookies";
// CHECK_EQ(1, 2) << ": The world must be ending!";
FLAGS_v = 2;
VLOG(1) << "I’m printed when you run the program with --v=1 or higher";
VLOG(2) << "I’m printed when you run the program with --v=2 or higher";
google::ShutdownGoogleLogging();
} and l get error
|
/cc @drigz |
@luliyucoordinate The current Bazel integration doesn't seem to support it. You could try running |
@drigz it works, then l sending a PR bazel: add GLOG_CUSTOM_PREFIX_SUPPORT |
I want to change log prefix format. And I see the sentence "That feature must be enabled at compile time by the WITH_CUSTOM_PREFIX flag." in the document. But how do I use it in bazel?
The text was updated successfully, but these errors were encountered: