From e81923ec188c6f90fc43c34eb634af2d9dab11d9 Mon Sep 17 00:00:00 2001
From: "jochen@chromium.org"
 <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Date: Wed, 27 Jun 2012 08:58:19 +0000
Subject: Don't log to stderr when running layout tests in the content shell

BUG=111316
TEST=none

Review URL: https://chromiumcodereview.appspot.com/10636052

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@144420 0039d316-1c4b-4281-b951-d872f2087c98
---
 content/shell/shell_main_delegate.cc | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

(limited to 'content')

diff --git a/content/shell/shell_main_delegate.cc b/content/shell/shell_main_delegate.cc
index 05516c6..12cb139 100644
--- a/content/shell/shell_main_delegate.cc
+++ b/content/shell/shell_main_delegate.cc
@@ -6,6 +6,7 @@
 
 #include "base/command_line.h"
 #include "base/file_path.h"
+#include "base/logging.h"
 #include "base/path_service.h"
 #include "content/public/browser/browser_main_runner.h"
 #include "content/public/common/content_switches.h"
@@ -13,6 +14,7 @@
 #include "content/shell/shell_browser_main.h"
 #include "content/shell/shell_content_browser_client.h"
 #include "content/shell/shell_content_renderer_client.h"
+#include "content/shell/shell_switches.h"
 #include "ui/base/resource/resource_bundle.h"
 #include "ui/base/ui_base_paths.h"
 
@@ -20,6 +22,23 @@
 #include "content/shell/paths_mac.h"
 #endif  // OS_MACOSX
 
+namespace {
+
+void InitLogging() {
+  FilePath log_filename;
+  PathService::Get(base::DIR_EXE, &log_filename);
+  log_filename = log_filename.AppendASCII("content_shell.log");
+  logging::InitLogging(
+      log_filename.value().c_str(),
+      logging::LOG_ONLY_TO_FILE,
+      logging::LOCK_LOG_FILE,
+      logging::DELETE_OLD_LOG_FILE,
+      logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS);
+  logging::SetLogItems(true, true, true, true);
+}
+
+}  // namespace
+
 ShellMainDelegate::ShellMainDelegate() {
 }
 
@@ -30,6 +49,8 @@ ShellMainDelegate::~ShellMainDelegate() {
 }
 
 bool ShellMainDelegate::BasicStartupComplete(int* exit_code) {
+  if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDumpRenderTree))
+    InitLogging();
 #if defined(OS_MACOSX)
   OverrideFrameworkBundlePath();
 #endif
-- 
cgit v1.1