Skip to content
Snippets Groups Projects
Commit eb57ceac authored by Jaswant Panchumarti (Kitware)'s avatar Jaswant Panchumarti (Kitware)
Browse files

Fix logic for skipping preamble header with loguru

- The previous logic hacked the `g_stderr_verbosity` boolean
  to make loguru skip preamble header output during the `loguru::init`
  call.
- After the change from 12d82bb5,
  the `g_stderr_verbosity` was left in an inconsistent `WARNING`
  value when `argc == 0`.
- This commit fixes the logic by using the `loguru::g_preamble`
  variable to turn off preamble output during init. The state of
  this boolean is restored to it's previous value after init.
parent 0bf46f5a
No related merge requests found
......@@ -135,11 +135,12 @@ void vtkLogger::Init(int& argc, char* argv[], const char* verbosity_flag /*= "-v
loguru::g_preamble_time = false;
loguru::g_internal_verbosity = static_cast<loguru::Verbosity>(vtkLogger::InternalVerbosityLevel);
if (loguru::g_internal_verbosity > loguru::g_stderr_verbosity)
bool currentPreambleValue = loguru::g_preamble;
if (loguru::g_preamble && (loguru::g_internal_verbosity > loguru::g_stderr_verbosity))
{
// this avoids printing the preamble-header on stderr except for cases
// where the stderr log is guaranteed to have some log text generated.
loguru::g_stderr_verbosity = loguru::Verbosity_WARNING;
loguru::g_preamble = false;
}
loguru::Options options;
options.verbosity_flag = verbosity_flag;
......@@ -157,6 +158,7 @@ void vtkLogger::Init(int& argc, char* argv[], const char* verbosity_flag /*= "-v
}
loguru::init(
argc, argv, options); // initializes many things, one of them being g_stderr_verbosity
loguru::g_preamble = currentPreambleValue;
#else
(void)argc;
(void)argv;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment