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 <string> | 10 #include <string> |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 // message text. | 44 // message text. |
45 LOG_MESSAGE_WITH_STACKTRACE = 11, | 45 LOG_MESSAGE_WITH_STACKTRACE = 11, |
46 // A message with: | 46 // A message with: |
47 // a stack trace, | 47 // a stack trace, |
48 // the line number as a four byte integer, | 48 // the line number as a four byte integer, |
49 // the file as a zero terminated UTF8 string, | 49 // the file as a zero terminated UTF8 string, |
50 // the zero-terminated UTF8 message text. | 50 // the zero-terminated UTF8 message text. |
51 LOG_MESSAGE_FULL = 12, | 51 LOG_MESSAGE_FULL = 12, |
52 }; | 52 }; |
53 | 53 |
54 class WinLogMessageHandler : LogMessageHandler { | |
grt (UTC plus 2)
2016/07/27 20:38:21
move this into the private: section of LogEventPro
wychen
2016/08/01 16:12:26
Done.
| |
55 bool OnMessage(logging::LogSeverity severity, const char* file, | |
grt (UTC plus 2)
2016/07/27 20:38:21
public:
wychen
2016/08/01 16:12:26
Done.
| |
56 int line, size_t message_start, const std::string& str) override; | |
57 }; | |
58 | |
54 // Trace provider class to drive log control and transport | 59 // Trace provider class to drive log control and transport |
55 // with Event Tracing for Windows. | 60 // with Event Tracing for Windows. |
56 class BASE_EXPORT LogEventProvider : public base::win::EtwTraceProvider { | 61 class BASE_EXPORT LogEventProvider : public base::win::EtwTraceProvider { |
57 public: | 62 public: |
58 static LogEventProvider* GetInstance(); | 63 static LogEventProvider* GetInstance(); |
59 | 64 |
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); | 65 static void Initialize(const GUID& provider_name); |
64 static void Uninitialize(); | 66 static void Uninitialize(); |
65 | 67 |
66 protected: | 68 protected: |
67 // Overridden to manipulate the log level on ETW control callbacks. | 69 // Overridden to manipulate the log level on ETW control callbacks. |
68 void OnEventsEnabled() override; | 70 void OnEventsEnabled() override; |
69 void OnEventsDisabled() override; | 71 void OnEventsDisabled() override; |
70 | 72 |
71 private: | 73 private: |
74 friend class WinLogMessageHandler; | |
72 LogEventProvider(); | 75 LogEventProvider(); |
73 | 76 |
74 // The log severity prior to OnEventsEnabled, | 77 // The log severity prior to OnEventsEnabled, |
75 // restored in OnEventsDisabled. | 78 // restored in OnEventsDisabled. |
76 logging::LogSeverity old_log_level_; | 79 logging::LogSeverity old_log_level_; |
77 | 80 |
78 friend struct base::StaticMemorySingletonTraits<LogEventProvider>; | 81 friend struct base::StaticMemorySingletonTraits<LogEventProvider>; |
79 DISALLOW_COPY_AND_ASSIGN(LogEventProvider); | 82 DISALLOW_COPY_AND_ASSIGN(LogEventProvider); |
80 }; | 83 }; |
81 | 84 |
82 } // namespace logging | 85 } // namespace logging |
83 | 86 |
84 #endif // BASE_LOGGING_WIN_H_ | 87 #endif // BASE_LOGGING_WIN_H_ |
OLD | NEW |