Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BASE_LOGGING_WIN_H_ | 5 #ifndef BASE_LOGGING_WIN_H_ |
| 6 #define BASE_LOGGING_WIN_H_ | 6 #define BASE_LOGGING_WIN_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/win/event_trace_provider.h" | 11 #include "base/win/event_trace_provider.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/singleton.h" | |
|
M-A Ruel
2010/12/03 21:06:07
I think you could forward declare the trait instea
Satish
2010/12/04 23:00:40
Done.
| |
| 13 | 14 |
| 14 namespace logging { | 15 namespace logging { |
| 15 | 16 |
| 16 // Event ID for the log messages we generate. | 17 // Event ID for the log messages we generate. |
| 17 extern const GUID kLogEventId; | 18 extern const GUID kLogEventId; |
| 18 | 19 |
| 19 // Feature enable mask for LogEventProvider. | 20 // Feature enable mask for LogEventProvider. |
| 20 enum LogEnableMask { | 21 enum LogEnableMask { |
| 21 // If this bit is set in our provider enable mask, we will include | 22 // If this bit is set in our provider enable mask, we will include |
| 22 // a stack trace with every log message. | 23 // a stack trace with every log message. |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 40 // the line number as a four byte integer, | 41 // the line number as a four byte integer, |
| 41 // the file as a zero terminated UTF8 string, | 42 // the file as a zero terminated UTF8 string, |
| 42 // the zero-terminated UTF8 message text. | 43 // the zero-terminated UTF8 message text. |
| 43 LOG_MESSAGE_FULL = 12, | 44 LOG_MESSAGE_FULL = 12, |
| 44 }; | 45 }; |
| 45 | 46 |
| 46 // Trace provider class to drive log control and transport | 47 // Trace provider class to drive log control and transport |
| 47 // with Event Tracing for Windows. | 48 // with Event Tracing for Windows. |
| 48 class LogEventProvider : public base::win::EtwTraceProvider { | 49 class LogEventProvider : public base::win::EtwTraceProvider { |
| 49 public: | 50 public: |
| 50 LogEventProvider(); | 51 static LogEventProvider* GetInstance(); |
| 51 | 52 |
| 52 static bool LogMessage(logging::LogSeverity severity, const char* file, | 53 static bool LogMessage(logging::LogSeverity severity, const char* file, |
| 53 int line, size_t message_start, const std::string& str); | 54 int line, size_t message_start, const std::string& str); |
| 54 | 55 |
| 55 static void Initialize(const GUID& provider_name); | 56 static void Initialize(const GUID& provider_name); |
| 56 static void Uninitialize(); | 57 static void Uninitialize(); |
| 57 | 58 |
| 58 protected: | 59 protected: |
| 59 // Overridden to manipulate the log level on ETW control callbacks. | 60 // Overridden to manipulate the log level on ETW control callbacks. |
| 60 virtual void OnEventsEnabled(); | 61 virtual void OnEventsEnabled(); |
| 61 virtual void OnEventsDisabled(); | 62 virtual void OnEventsDisabled(); |
| 62 | 63 |
| 63 private: | 64 private: |
| 65 LogEventProvider(); | |
| 66 | |
| 64 // The log severity prior to OnEventsEnabled, | 67 // The log severity prior to OnEventsEnabled, |
| 65 // restored in OnEventsDisabled. | 68 // restored in OnEventsDisabled. |
| 66 logging::LogSeverity old_log_level_; | 69 logging::LogSeverity old_log_level_; |
| 67 | 70 |
| 71 friend StaticMemorySingletonTraits<LogEventProvider>; | |
| 68 DISALLOW_COPY_AND_ASSIGN(LogEventProvider); | 72 DISALLOW_COPY_AND_ASSIGN(LogEventProvider); |
| 69 }; | 73 }; |
| 70 | 74 |
| 71 } // namespace logging | 75 } // namespace logging |
| 72 | 76 |
| 73 #endif // BASE_LOGGING_WIN_H_ | 77 #endif // BASE_LOGGING_WIN_H_ |
| OLD | NEW |