From 2b07b84191a266cb8c9dd86b6957df4947b136e0 Mon Sep 17 00:00:00 2001 From: "siggi@chromium.org" Date: Wed, 25 Nov 2009 15:26:34 +0000 Subject: Integrate the base logging with Event Tracing for Windows. This allows ETW to control the log level and log feature flags from outside the process, and all log messages can be transported into ETW trace sessions.As is this provides an event trace provider class thatmanages the log level on control callbacks and shunts the formatted log messages to ETW when warranted.The provider observes one feature flag, which when turned on causes it to capture and log a stack trace at the log site, which can be helpful when diagnosing errors from logs.This CL also initializes ETW logging for chrome.dll, but only if the environment variable "CHROME_ETW_LOGGING" is set. The ETW machinery may create a thread in every process registering a trace provider, and the environment variable makes this overhead optional. TEST=Unittests in this change BUG=none Review URL: http://codereview.chromium.org/413006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33066 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/common/logging_chrome.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'chrome/common/logging_chrome.cc') diff --git a/chrome/common/logging_chrome.cc b/chrome/common/logging_chrome.cc index c8580be..c957782 100644 --- a/chrome/common/logging_chrome.cc +++ b/chrome/common/logging_chrome.cc @@ -45,6 +45,10 @@ #include "chrome/common/env_vars.h" #include "ipc/ipc_logging.h" #include "ipc/ipc_message.h" +#if defined(OS_WIN) +#include "base/logging_win.h" +#include +#endif // When true, this means that error dialogs should not be shown. static bool dialogs_are_suppressed_ = false; @@ -53,6 +57,12 @@ static bool dialogs_are_suppressed_ = false; // InitChromeLogging() and the beginning of CleanupChromeLogging(). static bool chrome_logging_initialized_ = false; +#if defined(OS_WIN) +// {7FE69228-633E-4f06-80C1-527FEA23E3A7} +DEFINE_GUID(kChromeTraceProviderName, + 0x7fe69228, 0x633e, 0x4f06, 0x80, 0xc1, 0x52, 0x7f, 0xea, 0x23, 0xe3, 0xa7); +#endif + // Assertion handler for logging errors that occur when dialogs are // silenced. To record a new error, pass the log string associated // with that error in the str parameter. @@ -157,6 +167,12 @@ void InitChromeLogging(const CommandLine& command_line, logging::SetMinLogLevel(LOG_WARNING); } +#if defined(OS_WIN) + // Enable trace control and transport through event tracing for Windows. + if (base::SysInfo::HasEnvVar(env_vars::kEtwLogging)) + logging::LogEventProvider::Initialize(kChromeTraceProviderName); +#endif + chrome_logging_initialized_ = true; } -- cgit v1.1