1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef BASE_LOGGING_WIN_H_
6 #define BASE_LOGGING_WIN_H_
10 #include "base/basictypes.h"
11 #include "base/event_trace_provider_win.h"
12 #include "base/logging.h"
16 // Event ID for the log messages we generate.
17 extern const GUID kLogEventId
;
19 // Feature enable mask for LogEventProvider.
21 // If this bit is set in our provider enable mask, we will include
22 // a stack trace with every log message.
23 ENABLE_STACK_TRACE_CAPTURE
= 0x0001,
26 // The message types our log event provider generates.
27 // ETW likes user message types to start at 10.
28 enum LogMessageTypes
{
29 // A textual only log message, contains a zero-terminated string.
31 // A message with a stack trace, followed by the zero-terminated
33 LOG_MESSAGE_WITH_STACKTRACE
= 11,
36 // Trace provider class to drive log control and transport
37 // with Event Tracing for Windows.
38 class LogEventProvider
: public EtwTraceProvider
{
42 static bool LogMessage(int severity
, const std::string
& message
);
43 static void Initialize(const GUID
& provider_name
);
44 static void Uninitialize();
47 // Overridden to manipulate the log level on ETW control callbacks.
48 virtual void OnEventsEnabled();
49 virtual void OnEventsDisabled();
52 // The log severity prior to OnEventsEnabled,
53 // restored in OnEventsDisabled.
54 logging::LogSeverity old_log_level_
;
56 DISALLOW_COPY_AND_ASSIGN(LogEventProvider
);
59 } // namespace logging
61 #endif // BASE_LOGGING_WIN_H_