Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Unified Diff: chrome/test/base/file_logger_win.h

Issue 9584017: New test infrastructure for producing verbose logs in failing tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment updates Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/base/file_logger_win.h
diff --git a/chrome/test/base/file_logger_win.h b/chrome/test/base/file_logger_win.h
new file mode 100644
index 0000000000000000000000000000000000000000..97b1c3f95021743d12de2b836a6f3b3f3ab461f6
--- /dev/null
+++ b/chrome/test/base/file_logger_win.h
@@ -0,0 +1,77 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_TEST_BASE_FILE_LOGGER_WIN_H_
+#define CHROME_TEST_BASE_FILE_LOGGER_WIN_H_
+#pragma once
+
+#include <guiddef.h>
+
+#include <ostream>
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/win/event_trace_controller.h"
+
+class FilePath;
+
+// A file logger instance captures LOG messages emitted as events via Event
+// Tracing for Windows (ETW) and sends them to a file. The contents of such a
+// file can be sent to an output stream sometime later. Due to the nature of
+// event generation, only one instance of this class may be initialized at a
+// time.
robertshield 2012/03/02 22:37:41 Consider adding a note here that this requires adm
grt (UTC plus 2) 2012/03/03 02:12:43 Done.
+class FileLogger {
+ public:
+ FileLogger();
+ ~FileLogger();
+
+ // Initializes the instance to collect logs from the default set of providers:
+ // - chrome.exe
+ // - npchrome_frame.dll
+ // - this test binary.
+ // The system-wide variable CHROME_ETW_LOGGING=1 is added to the environment
+ // if it is not present.
robertshield 2012/03/02 22:37:41 * The variable CHROME_ETW_LOGGING=1 is added to th
grt (UTC plus 2) 2012/03/03 02:12:43 Done.
+ void Initialize();
+
+ // Initializes the instance to collect logs from the given providers.
+ void Initialize(const GUID* const* provider_names, size_t provider_count);
+
+ // Removes the system-wide CHROME_ETW_LOGGING=1 variable from the environment
+ // if it was inserted in Initialize().
+ void Uninitialize();
+
+ // Starts capturing logs from all providers into |log_file|. The common file
+ // extension for such files is .etl.
+ bool StartLogging(const FilePath& log_file);
+
+ // Stops capturing logs.
+ void StopLogging();
+
+ // Returns true if logs are being captured.
+ bool is_logging() const {
+ return controller_.session_name() && *controller_.session_name();
+ }
+
+ // Dumps all messages in |log_file|, which must have been produced by an
+ // instance of this class, to |out|.
+ static void DumpLogFile(const FilePath& log_file, std::ostream& out);
+
+ private:
+ bool EnableProviders();
+ void DisableProviders();
+
+ void ConfigureChromeEtwLogging();
+ void RevertChromeEtwLogging();
+
+ std::vector<GUID> provider_names_;
+ base::win::EtwTraceController controller_;
+
+ // True if the system-wide variable CHROME_ETW_LOGGING=1 was inserted into the
+ // environment.
+ bool added_chrome_etw_variable_;
+
+ DISALLOW_COPY_AND_ASSIGN(FileLogger);
+};
+
+#endif // CHROME_TEST_BASE_FILE_LOGGER_WIN_H_

Powered by Google App Engine
This is Rietveld 408576698