security/sandbox/chromium/base/logging_win.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/sandbox/chromium/base/logging_win.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,80 @@
     1.4 +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
     1.5 +// Use of this source code is governed by a BSD-style license that can be
     1.6 +// found in the LICENSE file.
     1.7 +
     1.8 +#ifndef BASE_LOGGING_WIN_H_
     1.9 +#define BASE_LOGGING_WIN_H_
    1.10 +
    1.11 +#include <string>
    1.12 +
    1.13 +#include "base/base_export.h"
    1.14 +#include "base/basictypes.h"
    1.15 +#include "base/win/event_trace_provider.h"
    1.16 +#include "base/logging.h"
    1.17 +
    1.18 +template <typename Type>
    1.19 +struct StaticMemorySingletonTraits;
    1.20 +
    1.21 +namespace logging {
    1.22 +
    1.23 +// Event ID for the log messages we generate.
    1.24 +EXTERN_C BASE_EXPORT const GUID kLogEventId;
    1.25 +
    1.26 +// Feature enable mask for LogEventProvider.
    1.27 +enum LogEnableMask {
    1.28 +  // If this bit is set in our provider enable mask, we will include
    1.29 +  // a stack trace with every log message.
    1.30 +  ENABLE_STACK_TRACE_CAPTURE = 0x0001,
    1.31 +  // If this bit is set in our provider enable mask, the provider will log
    1.32 +  // a LOG message with only the textual content of the message, and no
    1.33 +  // stack trace.
    1.34 +  ENABLE_LOG_MESSAGE_ONLY = 0x0002,
    1.35 +};
    1.36 +
    1.37 +// The message types our log event provider generates.
    1.38 +// ETW likes user message types to start at 10.
    1.39 +enum LogMessageTypes {
    1.40 +  // A textual only log message, contains a zero-terminated string.
    1.41 +  LOG_MESSAGE = 10,
    1.42 +  // A message with a stack trace, followed by the zero-terminated
    1.43 +  // message text.
    1.44 +  LOG_MESSAGE_WITH_STACKTRACE = 11,
    1.45 +  // A message with:
    1.46 +  //  a stack trace,
    1.47 +  //  the line number as a four byte integer,
    1.48 +  //  the file as a zero terminated UTF8 string,
    1.49 +  //  the zero-terminated UTF8 message text.
    1.50 +  LOG_MESSAGE_FULL = 12,
    1.51 +};
    1.52 +
    1.53 +// Trace provider class to drive log control and transport
    1.54 +// with Event Tracing for Windows.
    1.55 +class BASE_EXPORT LogEventProvider : public base::win::EtwTraceProvider {
    1.56 + public:
    1.57 +  static LogEventProvider* GetInstance();
    1.58 +
    1.59 +  static bool LogMessage(logging::LogSeverity severity, const char* file,
    1.60 +      int line, size_t message_start, const std::string& str);
    1.61 +
    1.62 +  static void Initialize(const GUID& provider_name);
    1.63 +  static void Uninitialize();
    1.64 +
    1.65 + protected:
    1.66 +  // Overridden to manipulate the log level on ETW control callbacks.
    1.67 +  virtual void OnEventsEnabled();
    1.68 +  virtual void OnEventsDisabled();
    1.69 +
    1.70 + private:
    1.71 +  LogEventProvider();
    1.72 +
    1.73 +  // The log severity prior to OnEventsEnabled,
    1.74 +  // restored in OnEventsDisabled.
    1.75 +  logging::LogSeverity old_log_level_;
    1.76 +
    1.77 +  friend struct StaticMemorySingletonTraits<LogEventProvider>;
    1.78 +  DISALLOW_COPY_AND_ASSIGN(LogEventProvider);
    1.79 +};
    1.80 +
    1.81 +}  // namespace logging
    1.82 +
    1.83 +#endif  // BASE_LOGGING_WIN_H_

mercurial