Rename TF_CPP_MIN_VLOG_LEVEL to TF_CPP_MAX_VLOG_LEVEL

"Max" is the correct qualifier: setting it to `N` means VLOG(k) won't be printed
if k > N.

PiperOrigin-RevId: 348880128
Change-Id: I64d53eb5ed826be888dbfdce516fc7c11b554a0a
This commit is contained in:
Sanjoy Das 2020-12-23 20:00:34 -08:00 committed by TensorFlower Gardener
parent f02d09c62c
commit 7494180256
3 changed files with 14 additions and 13 deletions

View File

@ -5,7 +5,8 @@
## Breaking Changes
* <DOCUMENT BREAKING CHANGES HERE>
* <THIS SECTION SHOULD CONTAIN API, ABI AND BEHAVIORAL BREAKING CHANGES>
* The `TF_CPP_MIN_VLOG_LEVEL` environment variable has been renamed to to
`TF_CPP_MAX_VLOG_LEVEL` which correctly describes its effect.
## Known Caveats

View File

@ -271,7 +271,7 @@ int64 MinLogLevelFromEnv() {
#endif
}
int64 MinVLogLevelFromEnv() {
int64 MaxVLogLevelFromEnv() {
// We don't want to print logs during fuzzing as that would slow fuzzing down
// by almost 2x. So, if we are in fuzzing mode (not just running a test), we
// return a value so that nothing is actually printed. Since VLOG uses <=
@ -281,7 +281,7 @@ int64 MinVLogLevelFromEnv() {
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
return 0;
#else
const char* tf_env_var_val = getenv("TF_CPP_MIN_VLOG_LEVEL");
const char* tf_env_var_val = getenv("TF_CPP_MAX_VLOG_LEVEL");
return LogLevelStrToInt(tf_env_var_val);
#endif
}
@ -307,13 +307,13 @@ void LogMessage::GenerateLogMessage() {
TFLogSinks::Instance().Send(TFLogEntry(severity_, fname_, line_, str()));
}
int64 LogMessage::MinVLogLevel() {
static int64 min_vlog_level = MinVLogLevelFromEnv();
return min_vlog_level;
int64 LogMessage::MaxVLogLevel() {
static int64 max_vlog_level = MaxVLogLevelFromEnv();
return max_vlog_level;
}
bool LogMessage::VmoduleActivated(const char* fname, int level) {
if (level <= MinVLogLevel()) {
if (level <= MaxVLogLevel()) {
return true;
}
static VmoduleMap* vmodules = VmodulesMapFromEnv();

View File

@ -50,16 +50,16 @@ class LogMessage : public std::basic_ostringstream<char> {
// Change the location of the log message.
LogMessage& AtLocation(const char* fname, int line);
// Returns the minimum log level for VLOG statements.
// E.g., if MinVLogLevel() is 2, then VLOG(2) statements will produce output,
// Returns the maximum log level for VLOG statements.
// E.g., if MaxVLogLevel() is 2, then VLOG(2) statements will produce output,
// but VLOG(3) will not. Defaults to 0.
static int64 MinVLogLevel();
static int64 MaxVLogLevel();
// Returns whether VLOG level lvl is activated for the file fname.
//
// E.g. if the environment variable TF_CPP_VMODULE contains foo=3 and fname is
// foo.cc and lvl is <= 3, this will return true. It will also return true if
// the level is lower or equal to TF_CPP_MIN_VLOG_LEVEL (default zero).
// the level is lower or equal to TF_CPP_MAX_VLOG_LEVEL (default zero).
//
// It is expected that the result of this query will be cached in the VLOG-ing
// call site to avoid repeated lookups. This routine performs a hash-map
@ -117,7 +117,7 @@ class LogMessageNull : public std::basic_ostringstream<char> {
#else
// Otherwise, set TF_CPP_MIN_VLOG_LEVEL environment to update minimum log level
// Otherwise, set TF_CPP_MAX_VLOG_LEVEL environment to update minimum log level
// of VLOG, or TF_CPP_VMODULE to set the minimum log level for individual
// translation units.
#define VLOG_IS_ON(lvl) \
@ -462,7 +462,7 @@ T&& CheckNotNull(const char* file, int line, const char* exprtext, T&& t) {
int64 MinLogLevelFromEnv();
int64 MinVLogLevelFromEnv();
int64 MaxVLogLevelFromEnv();
} // namespace internal