Fix emulator build error
[platform/framework/web/chromium-efl.git] / base / logging_win.h
1 // Copyright 2012 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef BASE_LOGGING_WIN_H_
6 #define BASE_LOGGING_WIN_H_
7
8 #include <stddef.h>
9
10 #include <string>
11
12 #include "base/base_export.h"
13 #include "base/logging.h"
14 #include "base/win/event_trace_provider.h"
15
16 namespace base {
17 template <typename Type>
18 struct StaticMemorySingletonTraits;
19 }  // namespace base
20
21 namespace logging {
22
23 // Event ID for the log messages we generate.
24 EXTERN_C BASE_EXPORT const GUID kLogEventId;
25
26 // Feature enable mask for LogEventProvider.
27 enum LogEnableMask {
28   // If this bit is set in our provider enable mask, we will include
29   // a stack trace with every log message.
30   ENABLE_STACK_TRACE_CAPTURE = 0x0001,
31   // If this bit is set in our provider enable mask, the provider will log
32   // a LOG message with only the textual content of the message, and no
33   // stack trace.
34   ENABLE_LOG_MESSAGE_ONLY = 0x0002,
35 };
36
37 // The message types our log event provider generates.
38 // ETW likes user message types to start at 10.
39 enum LogMessageTypes {
40   // A textual only log message, contains a zero-terminated string.
41   LOG_MESSAGE = 10,
42   // A message with a stack trace, followed by the zero-terminated
43   // message text.
44   LOG_MESSAGE_WITH_STACKTRACE = 11,
45   // A message with:
46   //  a stack trace,
47   //  the line number as a four byte integer,
48   //  the file as a zero terminated UTF8 string,
49   //  the zero-terminated UTF8 message text.
50   LOG_MESSAGE_FULL = 12,
51 };
52
53 // Trace provider class to drive log control and transport
54 // with Event Tracing for Windows.
55 class BASE_EXPORT LogEventProvider : public base::win::EtwTraceProvider {
56  public:
57   LogEventProvider(const LogEventProvider&) = delete;
58   LogEventProvider& operator=(const LogEventProvider&) = delete;
59   static LogEventProvider* GetInstance();
60
61   static bool LogMessage(logging::LogSeverity severity, const char* file,
62       int line, size_t message_start, const std::string& str);
63
64   static void Initialize(const GUID& provider_name);
65   static void Uninitialize();
66
67  protected:
68   // Overridden to manipulate the log level on ETW control callbacks.
69   void OnEventsEnabled() override;
70   void OnEventsDisabled() override;
71
72  private:
73   LogEventProvider();
74
75   // The log severity prior to OnEventsEnabled,
76   // restored in OnEventsDisabled.
77   logging::LogSeverity old_log_level_;
78
79   friend struct base::StaticMemorySingletonTraits<LogEventProvider>;
80 };
81
82 }  // namespace logging
83
84 #endif  // BASE_LOGGING_WIN_H_