summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/core/content_main_delegate_qt.cpp40
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()