OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_TEST_LOGGING_WIN_FILE_LOGGER_H_ | 5 #ifndef CHROME_TEST_LOGGING_WIN_FILE_LOGGER_H_ |
6 #define CHROME_TEST_LOGGING_WIN_FILE_LOGGER_H_ | 6 #define CHROME_TEST_LOGGING_WIN_FILE_LOGGER_H_ |
7 | 7 |
8 #include <guiddef.h> | 8 #include <guiddef.h> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/string16.h" | 11 #include "base/string16.h" |
12 #include "base/win/event_trace_controller.h" | 12 #include "base/win/event_trace_controller.h" |
13 | 13 |
| 14 namespace base { |
14 class FilePath; | 15 class FilePath; |
| 16 } |
15 | 17 |
16 namespace logging_win { | 18 namespace logging_win { |
17 | 19 |
18 // A file logger instance captures LOG messages and trace events emitted via | 20 // A file logger instance captures LOG messages and trace events emitted via |
19 // Event Tracing for Windows (ETW) and sends them to a file. Events can be | 21 // Event Tracing for Windows (ETW) and sends them to a file. Events can be |
20 // pulled from the file sometime later with PrintLogFile or ReadLogFile | 22 // pulled from the file sometime later with PrintLogFile or ReadLogFile |
21 // (currently in log_file_printer_win.h and log_file_reader_win.h, | 23 // (currently in log_file_printer_win.h and log_file_reader_win.h, |
22 // respectively). | 24 // respectively). |
23 // | 25 // |
24 // Important usage notes (read this): | 26 // Important usage notes (read this): |
(...skipping 27 matching lines...) Expand all Loading... |
52 void Initialize(); | 54 void Initialize(); |
53 | 55 |
54 // Initializes the instance to collect logs from the providers present in | 56 // Initializes the instance to collect logs from the providers present in |
55 // the given mask; see EventProviderBits. | 57 // the given mask; see EventProviderBits. |
56 void Initialize(uint32 event_provider_mask); | 58 void Initialize(uint32 event_provider_mask); |
57 | 59 |
58 // Starts capturing logs from all providers into |log_file|. The common file | 60 // Starts capturing logs from all providers into |log_file|. The common file |
59 // extension for such files is .etl. Returns false if the session could not | 61 // extension for such files is .etl. Returns false if the session could not |
60 // be started (e.g., if not running as admin) or if no providers could be | 62 // be started (e.g., if not running as admin) or if no providers could be |
61 // enabled. | 63 // enabled. |
62 bool StartLogging(const FilePath& log_file); | 64 bool StartLogging(const base::FilePath& log_file); |
63 | 65 |
64 // Stops capturing logs. | 66 // Stops capturing logs. |
65 void StopLogging(); | 67 void StopLogging(); |
66 | 68 |
67 // Returns true if logs are being captured. | 69 // Returns true if logs are being captured. |
68 bool is_logging() const { | 70 bool is_logging() const { |
69 return controller_.session_name() && *controller_.session_name(); | 71 return controller_.session_name() && *controller_.session_name(); |
70 } | 72 } |
71 | 73 |
72 private: | 74 private: |
73 bool EnableProviders(); | 75 bool EnableProviders(); |
74 void DisableProviders(); | 76 void DisableProviders(); |
75 | 77 |
76 static bool is_initialized_; | 78 static bool is_initialized_; |
77 | 79 |
78 base::win::EtwTraceController controller_; | 80 base::win::EtwTraceController controller_; |
79 uint32 event_provider_mask_; | 81 uint32 event_provider_mask_; |
80 | 82 |
81 DISALLOW_COPY_AND_ASSIGN(FileLogger); | 83 DISALLOW_COPY_AND_ASSIGN(FileLogger); |
82 }; | 84 }; |
83 | 85 |
84 } // namespace logging_win | 86 } // namespace logging_win |
85 | 87 |
86 #endif // CHROME_TEST_LOGGING_WIN_FILE_LOGGER_H_ | 88 #endif // CHROME_TEST_LOGGING_WIN_FILE_LOGGER_H_ |
OLD | NEW |