security/sandbox/chromium/base/logging_win.h

Wed, 31 Dec 2014 07:16:47 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:16:47 +0100
branch
TOR_BUG_9701
changeset 3
141e0f1194b1
permissions
-rw-r--r--

Revert simplistic fix pending revisit of Mozilla integration attempt.

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

mercurial