Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does tensorflow's VLOG work?

Tags:

tensorflow

I used VLOG to print log, the VLOG is define as below:

#define VLOG_IS_ON(lvl) \
   ((lvl) <= ::tensorflow::internal::LogMessage::MinVLogLevel())
#endif

#define VLOG(lvl)      \
  if (TF_PREDICT_FALSE(VLOG_IS_ON(lvl))) \
  ::tensorflow::internal::LogMessage(__FILE__, __LINE__, tensorflow::INFO)

const int INFO = 0;            // base_logging::INFO;
const int WARNING = 1;         // base_logging::WARNING;
const int ERROR = 2;           // base_logging::ERROR;
const int FATAL = 3;           // base_logging::FATAL;
const int NUM_SEVERITIES = 4;  // base_logging::NUM_SEVERITIES;

if i config the min log level with warning, i use export TF_CPP_MIN_VLOG_LEVEL=1, what i want is the log only print WANRING and including ERROR、TATAL, but the fact is only display WARNING and INFO logs which are called by

VLOG(INFO) and VLOG(WARN)

Does this result reasonable?

like image 979
tong suo Avatar asked Jul 17 '17 10:07

tong suo


1 Answers

You control the log level via TF_CPP_MIN_LOG_LEVEL (not TF_CPP_MIN_VLOG_LEVEL), which you want to set to 1 in your case.

TF_CPP_MIN_VLOG_LEVEL brings in extra debugging information and actually works the other way round: its default value is 0 and as it increases, more debugging messages are logged in.

So the VLOG level is not your usual INFO, WARNING, etc. LOG level, but something different and ranked inversely. If you peek into the code, you see that LOG is used with log labels (LOG(INFO) << message) but VLOG is used with plain numbers (VLOG(2) << message).

VLOG messages are actually always logged at the INFO log level. It means that in any case, you need a TF_CPP_MIN_LOG_LEVEL of 0 to see any VLOG message.

like image 95
P-Gn Avatar answered Sep 21 '22 19:09

P-Gn