| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> |
| 10 #include <string> | 11 #include <string> |
| 11 | 12 |
| 12 #include "base/base_export.h" | 13 #include "base/base_export.h" |
| 13 #include "base/logging.h" | 14 #include "base/logging.h" |
| 14 #include "base/macros.h" | 15 #include "base/macros.h" |
| 15 #include "base/win/event_trace_provider.h" | 16 #include "base/win/event_trace_provider.h" |
| 16 | 17 |
| 17 namespace base { | 18 namespace base { |
| 18 template <typename Type> | 19 template <typename Type> |
| 19 struct StaticMemorySingletonTraits; | 20 struct StaticMemorySingletonTraits; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 50 // the zero-terminated UTF8 message text. | 51 // the zero-terminated UTF8 message text. |
| 51 LOG_MESSAGE_FULL = 12, | 52 LOG_MESSAGE_FULL = 12, |
| 52 }; | 53 }; |
| 53 | 54 |
| 54 // Trace provider class to drive log control and transport | 55 // Trace provider class to drive log control and transport |
| 55 // with Event Tracing for Windows. | 56 // with Event Tracing for Windows. |
| 56 class BASE_EXPORT LogEventProvider : public base::win::EtwTraceProvider { | 57 class BASE_EXPORT LogEventProvider : public base::win::EtwTraceProvider { |
| 57 public: | 58 public: |
| 58 static LogEventProvider* GetInstance(); | 59 static LogEventProvider* GetInstance(); |
| 59 | 60 |
| 60 static bool LogMessage(logging::LogSeverity severity, const char* file, | |
| 61 int line, size_t message_start, const std::string& str); | |
| 62 | |
| 63 static void Initialize(const GUID& provider_name); | 61 static void Initialize(const GUID& provider_name); |
| 64 static void Uninitialize(); | 62 static void Uninitialize(); |
| 65 | 63 |
| 66 protected: | 64 protected: |
| 67 // Overridden to manipulate the log level on ETW control callbacks. | 65 // Overridden to manipulate the log level on ETW control callbacks. |
| 68 void OnEventsEnabled() override; | 66 void OnEventsEnabled() override; |
| 69 void OnEventsDisabled() override; | 67 void OnEventsDisabled() override; |
| 70 | 68 |
| 71 private: | 69 private: |
| 72 LogEventProvider(); | 70 LogEventProvider(); |
| 71 ~LogEventProvider() override; |
| 73 | 72 |
| 73 class WinLogMessageHandler : LogMessageHandler { |
| 74 public: |
| 75 bool OnMessage(logging::LogSeverity severity, |
| 76 const char* file, |
| 77 int line, |
| 78 size_t message_start, |
| 79 const std::string& str) override; |
| 80 }; |
| 81 std::unique_ptr<WinLogMessageHandler> log_handler_; |
| 74 // The log severity prior to OnEventsEnabled, | 82 // The log severity prior to OnEventsEnabled, |
| 75 // restored in OnEventsDisabled. | 83 // restored in OnEventsDisabled. |
| 76 logging::LogSeverity old_log_level_; | 84 logging::LogSeverity old_log_level_; |
| 77 | 85 |
| 78 friend struct base::StaticMemorySingletonTraits<LogEventProvider>; | 86 friend struct base::StaticMemorySingletonTraits<LogEventProvider>; |
| 79 DISALLOW_COPY_AND_ASSIGN(LogEventProvider); | 87 DISALLOW_COPY_AND_ASSIGN(LogEventProvider); |
| 80 }; | 88 }; |
| 81 | 89 |
| 82 } // namespace logging | 90 } // namespace logging |
| 83 | 91 |
| 84 #endif // BASE_LOGGING_WIN_H_ | 92 #endif // BASE_LOGGING_WIN_H_ |
| OLD | NEW |