OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 |
| 11 #include "base/base_api.h" |
10 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
11 #include "base/win/event_trace_provider.h" | 13 #include "base/win/event_trace_provider.h" |
12 #include "base/logging.h" | 14 #include "base/logging.h" |
13 | 15 |
14 template <typename Type> | 16 template <typename Type> |
15 struct StaticMemorySingletonTraits; | 17 struct StaticMemorySingletonTraits; |
16 | 18 |
17 namespace logging { | 19 namespace logging { |
18 | 20 |
19 // Event ID for the log messages we generate. | 21 // Event ID for the log messages we generate. |
(...skipping 21 matching lines...) Expand all Loading... |
41 // A message with: | 43 // A message with: |
42 // a stack trace, | 44 // a stack trace, |
43 // the line number as a four byte integer, | 45 // the line number as a four byte integer, |
44 // the file as a zero terminated UTF8 string, | 46 // the file as a zero terminated UTF8 string, |
45 // the zero-terminated UTF8 message text. | 47 // the zero-terminated UTF8 message text. |
46 LOG_MESSAGE_FULL = 12, | 48 LOG_MESSAGE_FULL = 12, |
47 }; | 49 }; |
48 | 50 |
49 // Trace provider class to drive log control and transport | 51 // Trace provider class to drive log control and transport |
50 // with Event Tracing for Windows. | 52 // with Event Tracing for Windows. |
51 class LogEventProvider : public base::win::EtwTraceProvider { | 53 class BASE_API LogEventProvider : public base::win::EtwTraceProvider { |
52 public: | 54 public: |
53 static LogEventProvider* GetInstance(); | 55 static LogEventProvider* GetInstance(); |
54 | 56 |
55 static bool LogMessage(logging::LogSeverity severity, const char* file, | 57 static bool LogMessage(logging::LogSeverity severity, const char* file, |
56 int line, size_t message_start, const std::string& str); | 58 int line, size_t message_start, const std::string& str); |
57 | 59 |
58 static void Initialize(const GUID& provider_name); | 60 static void Initialize(const GUID& provider_name); |
59 static void Uninitialize(); | 61 static void Uninitialize(); |
60 | 62 |
61 protected: | 63 protected: |
62 // Overridden to manipulate the log level on ETW control callbacks. | 64 // Overridden to manipulate the log level on ETW control callbacks. |
63 virtual void OnEventsEnabled(); | 65 virtual void OnEventsEnabled(); |
64 virtual void OnEventsDisabled(); | 66 virtual void OnEventsDisabled(); |
65 | 67 |
66 private: | 68 private: |
67 LogEventProvider(); | 69 LogEventProvider(); |
68 | 70 |
69 // The log severity prior to OnEventsEnabled, | 71 // The log severity prior to OnEventsEnabled, |
70 // restored in OnEventsDisabled. | 72 // restored in OnEventsDisabled. |
71 logging::LogSeverity old_log_level_; | 73 logging::LogSeverity old_log_level_; |
72 | 74 |
73 friend struct StaticMemorySingletonTraits<LogEventProvider>; | 75 friend struct StaticMemorySingletonTraits<LogEventProvider>; |
74 DISALLOW_COPY_AND_ASSIGN(LogEventProvider); | 76 DISALLOW_COPY_AND_ASSIGN(LogEventProvider); |
75 }; | 77 }; |
76 | 78 |
77 } // namespace logging | 79 } // namespace logging |
78 | 80 |
79 #endif // BASE_LOGGING_WIN_H_ | 81 #endif // BASE_LOGGING_WIN_H_ |
OLD | NEW |