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

Side by Side 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, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 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.
4
5 #ifndef CHROME_TEST_BASE_FILE_LOGGER_WIN_H_
6 #define CHROME_TEST_BASE_FILE_LOGGER_WIN_H_
7 #pragma once
8
9 #include <guiddef.h>
10
11 #include <ostream>
12 #include <vector>
13
14 #include "base/basictypes.h"
15 #include "base/win/event_trace_controller.h"
16
17 class FilePath;
18
19 // A file logger instance captures LOG messages emitted as events via Event
20 // Tracing for Windows (ETW) and sends them to a file. The contents of such a
21 // file can be sent to an output stream sometime later. Due to the nature of
22 // event generation, only one instance of this class may be initialized at a
23 // 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.
24 class FileLogger {
25 public:
26 FileLogger();
27 ~FileLogger();
28
29 // Initializes the instance to collect logs from the default set of providers:
30 // - chrome.exe
31 // - npchrome_frame.dll
32 // - this test binary.
33 // The system-wide variable CHROME_ETW_LOGGING=1 is added to the environment
34 // 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.
35 void Initialize();
36
37 // Initializes the instance to collect logs from the given providers.
38 void Initialize(const GUID* const* provider_names, size_t provider_count);
39
40 // Removes the system-wide CHROME_ETW_LOGGING=1 variable from the environment
41 // if it was inserted in Initialize().
42 void Uninitialize();
43
44 // Starts capturing logs from all providers into |log_file|. The common file
45 // extension for such files is .etl.
46 bool StartLogging(const FilePath& log_file);
47
48 // Stops capturing logs.
49 void StopLogging();
50
51 // Returns true if logs are being captured.
52 bool is_logging() const {
53 return controller_.session_name() && *controller_.session_name();
54 }
55
56 // Dumps all messages in |log_file|, which must have been produced by an
57 // instance of this class, to |out|.
58 static void DumpLogFile(const FilePath& log_file, std::ostream& out);
59
60 private:
61 bool EnableProviders();
62 void DisableProviders();
63
64 void ConfigureChromeEtwLogging();
65 void RevertChromeEtwLogging();
66
67 std::vector<GUID> provider_names_;
68 base::win::EtwTraceController controller_;
69
70 // True if the system-wide variable CHROME_ETW_LOGGING=1 was inserted into the
71 // environment.
72 bool added_chrome_etw_variable_;
73
74 DISALLOW_COPY_AND_ASSIGN(FileLogger);
75 };
76
77 #endif // CHROME_TEST_BASE_FILE_LOGGER_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698