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