1

Is it possible to add custom log level to glog? I couldn't find any examples in their documentation.

Tried to edit glog/logging.h but program is crashing with following bt.

#0 0x00007f6aacaca1e6 in google::LogMessage::Init(char const*, int, int, void (google::LogMessage::*)()) () from /usr/lib/x86_64-linux-gnu/libglog.so.0

#1 0x00007f6aacac9b13 in google::LogMessage::LogMessage(char const*, int, int) () from /usr/lib/x86_64-linux-gnu/libglog.so.0

Ryan Haining
  • 35,360
  • 15
  • 114
  • 174
Nick
  • 375
  • 1
  • 2
  • 9

1 Answers1

2

VLOG(N) allows you to add your own set of log levels. N is some integer value. The command line flag --v=X will enable logging for all VLOG messages at X or lower

VLOG(10) << "not very important";
VLOG(1) << "maybe a little important";
VLOG(0) << "quite important";

You could write your own set of constant integer expressions definitions to pass to VLOG rather than using them directly.

Ryan Haining
  • 35,360
  • 15
  • 114
  • 174
  • I am trying to add another trace level called "PERF" along with ERROR,INFO,DEBUG,FATAL. exclusively to log performance metrics. is this possible? – Nick Feb 17 '17 at 02:09
  • @Nick not without some [heavy lifting](https://github.com/google/glog/blob/ab6545470bdb6fb14442923b2aa3289983bea968/src/windows/glog/logging.h#L502) The api doesn't appear to be designed to support this behavior – Ryan Haining Feb 17 '17 at 02:13