glog
glog copied to clipboard
why `VLOG(verboselevel)` is better than `LOG(severity)` when both don't output log?
Dear Sirs,
I replaced VLOG(1)
with LOG(INFO)
in my service for uniformity after which i was confused why the performance became worse . (Average latency increased 2ms and cpu usage increased 100%...).
I prebuilt VLOG(1)
and LOG(INFO)
and found the reason:
After prebuilding LOG(INFO):
google::LogMessage( "test_glog.cpp", 22).stream() << "Debug test count: " << i;
After prebuilding VLOG(1):
!(__extension__ ({ static google::int32* vlocal__ = &google::kLogSiteUninitialized; google::int32 verbose_level__ = (1); (*vlocal__ >= verbose_level__) && ((vlocal__ != &google::kLogSiteUninitialized) || (google::InitVLOG3__(&vlocal__, &FLAGS_v, "ads/serving/api/api_server.cpp", verbose_level__))); })) ? (void) 0 : google::LogMessageVoidify() & google::LogMessage( "test_glog.cpp", 29).stream() << "Debug test count: " << i;
LOG(INFO)
constructed directly even if the log severity didn't meet configuration(-minloglevel=2).
VLOG(1)
will judge firstly and not construct any more if not meet configuration(-v=0)
Did i misunderstanding something? Why LOG(INFO)
is designed like this? I think it is misleading and may affect many services' performance...
Will you change it like this:
#define LOG(INFO) if(condition) then LOG(INFO)_REAL
?
BestWishes, Shinan.
I'm curious about this too.