diff options
author | siggi@chromium.org <siggi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-25 15:26:34 +0000 |
---|---|---|
committer | siggi@chromium.org <siggi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-25 15:26:34 +0000 |
commit | 2b07b84191a266cb8c9dd86b6957df4947b136e0 (patch) | |
tree | bbe263aa264dc1cb12ad0d84d265b4580b93cb25 /base/logging.cc | |
parent | 458d689228b12028f02d632c091ad1f637bbc15b (diff) | |
download | chromium_src-2b07b84191a266cb8c9dd86b6957df4947b136e0.zip chromium_src-2b07b84191a266cb8c9dd86b6957df4947b136e0.tar.gz chromium_src-2b07b84191a266cb8c9dd86b6957df4947b136e0.tar.bz2 |
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
Diffstat (limited to 'base/logging.cc')
-rw-r--r-- | base/logging.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/base/logging.cc b/base/logging.cc index b59e3fb..e9cfc7a 100644 --- a/base/logging.cc +++ b/base/logging.cc @@ -98,6 +98,8 @@ LogAssertHandlerFunction log_assert_handler = NULL; // An report handler override specified by the client to be called instead of // the debug message dialog. LogReportHandlerFunction log_report_handler = NULL; +// A log message handler that gets notified of every log message we process. +LogMessageHandlerFunction log_message_handler = NULL; // The lock is used if log file locking is false. It helps us avoid problems // with multiple threads writing to the log file at the same time. Use @@ -312,6 +314,11 @@ void SetLogReportHandler(LogReportHandlerFunction handler) { log_report_handler = handler; } +void SetLogMessageHandler(LogMessageHandlerFunction handler) { + log_message_handler = handler; +} + + // Displays a message box to the user with the error message in it. For // Windows programs, it's possible that the message loop is messed up on // a fatal error, and creating a MessageBox will cause that message loop @@ -446,6 +453,9 @@ LogMessage::~LogMessage() { #else str_newline.append("\n"); #endif + // Give any log message handler first dibs on the message. + if (log_message_handler && log_message_handler(severity_, str_newline)) + return; if (log_filter_prefix && severity_ <= kMaxFilteredLogLevel && str_newline.compare(message_start_, log_filter_prefix->size(), |