diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2016-01-14 15:04:43 +0100 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@theqtcompany.com> | 2016-04-21 11:00:35 +0000 |
commit | f505e9eb516489ac5a0b7dac1b2fad3c75751bad (patch) | |
tree | cd363f34b46346d23104ccf2ecc5457e3ec3a494 /src/core/content_main_delegate_qt.cpp | |
parent | 7d76c6b2cd8989f134f678789bba2f13ed019153 (diff) |
Parse logging verbosity levels
Call logging::InitLogging so arguments such as --v and --vmodule are parsed
and used to configure chromium logging levels.
Change-Id: I44f8ed6b0ca9db4d606ced383c269566218383ad
Reviewed-by: Michael BrĂ¼ning <michael.bruning@theqtcompany.com>
Diffstat (limited to 'src/core/content_main_delegate_qt.cpp')
-rw-r--r-- | src/core/content_main_delegate_qt.cpp | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/src/core/content_main_delegate_qt.cpp b/src/core/content_main_delegate_qt.cpp index ee52dd23e..85eb984a0 100644 --- a/src/core/content_main_delegate_qt.cpp +++ b/src/core/content_main_delegate_qt.cpp @@ -71,6 +71,25 @@ static base::StringPiece PlatformResourceProvider(int key) { return base::StringPiece(); } +static logging::LoggingDestination DetermineLogMode(const base::CommandLine& command_line) +{ +#ifdef NDEBUG + bool enable_logging = false; + const char *kInvertLoggingSwitch = switches::kEnableLogging; +#else + bool enable_logging = true; + const char *kInvertLoggingSwitch = switches::kDisableLogging; +#endif + + if (command_line.HasSwitch(kInvertLoggingSwitch)) + enable_logging = !enable_logging; + + if (enable_logging) + return logging::LOG_TO_SYSTEM_DEBUG_LOG; + else + return logging::LOG_NONE; +} + void ContentMainDelegateQt::PreSandboxStartup() { #if defined(ARCH_CPU_ARM_FAMILY) && (defined(OS_ANDROID) || defined(OS_LINUX)) @@ -82,18 +101,19 @@ void ContentMainDelegateQt::PreSandboxStartup() net::NetModule::SetResourceProvider(PlatformResourceProvider); ui::ResourceBundle::InitSharedInstanceWithLocale(WebEngineLibraryInfo::getApplicationLocale(), 0, ui::ResourceBundle::LOAD_COMMON_RESOURCES); - // Suppress info, warning and error messages per default. - int logLevel = logging::LOG_FATAL; - base::CommandLine* parsedCommandLine = base::CommandLine::ForCurrentProcess(); - if (parsedCommandLine->HasSwitch(switches::kLoggingLevel)) { - std::string logLevelValue = parsedCommandLine->GetSwitchValueASCII(switches::kLoggingLevel); - int level = 0; - if (base::StringToInt(logLevelValue, &level) && level >= logging::LOG_INFO && level < logging::LOG_NUM_SEVERITIES) - logLevel = level; + logging::LoggingSettings settings; + settings.logging_dest = DetermineLogMode(*parsedCommandLine); + logging::InitLogging(settings); + + if (logging::GetMinLogLevel() >= logging::LOG_INFO) { + if (parsedCommandLine->HasSwitch(switches::kLoggingLevel)) { + std::string logLevelValue = parsedCommandLine->GetSwitchValueASCII(switches::kLoggingLevel); + int level = 0; + if (base::StringToInt(logLevelValue, &level) && level >= logging::LOG_INFO && level < logging::LOG_NUM_SEVERITIES) + logging::SetMinLogLevel(level); + } } - - logging::SetMinLogLevel(logLevel); } content::ContentBrowserClient *ContentMainDelegateQt::CreateContentBrowserClient() |