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

Side by Side Diff: chrome/test/logging/win/log_file_printer.cc

Issue 1376793004: Remove the TRACE_EVENT_*_ETW macros. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 2 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
« no previous file with comments | « chrome/test/logging/win/file_logger.cc ('k') | chrome/test/logging/win/log_file_reader.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "chrome/test/logging/win/log_file_printer.h" 5 #include "chrome/test/logging/win/log_file_printer.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <objbase.h> 8 #include <objbase.h>
9 9
10 #include <iomanip> 10 #include <iomanip>
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 int line, 58 int line,
59 std::ostream* out) { 59 std::ostream* out) {
60 base::StringPiece filename(file); 60 base::StringPiece filename(file);
61 size_t last_slash_pos = filename.find_last_of("\\/"); 61 size_t last_slash_pos = filename.find_last_of("\\/");
62 if (last_slash_pos != base::StringPiece::npos) 62 if (last_slash_pos != base::StringPiece::npos)
63 filename.remove_prefix(last_slash_pos + 1); 63 filename.remove_prefix(last_slash_pos + 1);
64 64
65 *out << filename << '(' << line << ')'; 65 *out << filename << '(' << line << ')';
66 } 66 }
67 67
68 // Returns a pretty string for the trace event types that appear in ETW logs.
69 const char* GetTraceTypeString(char event_type) {
70 switch (event_type) {
71 case TRACE_EVENT_PHASE_BEGIN:
72 return "BEGIN";
73 break;
74 case TRACE_EVENT_PHASE_END:
75 return "END";
76 break;
77 case TRACE_EVENT_PHASE_INSTANT:
78 return "INSTANT";
79 break;
80 default:
81 NOTREACHED();
82 return "";
83 break;
84 }
85 }
86
87 class EventPrinter : public logging_win::LogFileDelegate { 68 class EventPrinter : public logging_win::LogFileDelegate {
88 public: 69 public:
89 explicit EventPrinter(std::ostream* out); 70 explicit EventPrinter(std::ostream* out);
90 ~EventPrinter() override; 71 ~EventPrinter() override;
91 72
92 void OnUnknownEvent(const EVENT_TRACE* event) override; 73 void OnUnknownEvent(const EVENT_TRACE* event) override;
93 74
94 void OnUnparsableEvent(const EVENT_TRACE* event) override; 75 void OnUnparsableEvent(const EVENT_TRACE* event) override;
95 76
96 void OnFileHeader(const EVENT_TRACE* event, 77 void OnFileHeader(const EVENT_TRACE* event,
97 const TRACE_LOGFILE_HEADER* header) override; 78 const TRACE_LOGFILE_HEADER* header) override;
98 79
99 void OnLogMessage(const EVENT_TRACE* event, 80 void OnLogMessage(const EVENT_TRACE* event,
100 logging::LogSeverity severity, 81 logging::LogSeverity severity,
101 const base::StringPiece& message) override; 82 const base::StringPiece& message) override;
102 83
103 void OnLogMessageFull(const EVENT_TRACE* event, 84 void OnLogMessageFull(const EVENT_TRACE* event,
104 logging::LogSeverity severity, 85 logging::LogSeverity severity,
105 DWORD stack_depth, 86 DWORD stack_depth,
106 const intptr_t* backtrace, 87 const intptr_t* backtrace,
107 int line, 88 int line,
108 const base::StringPiece& file, 89 const base::StringPiece& file,
109 const base::StringPiece& message) override; 90 const base::StringPiece& message) override;
110 91
111 void OnTraceEvent(const EVENT_TRACE* event,
112 const base::StringPiece& name,
113 char type,
114 intptr_t id,
115 const base::StringPiece& extra,
116 DWORD stack_depth,
117 const intptr_t* backtrace) override;
118
119 private: 92 private:
120 void PrintTimeStamp(LARGE_INTEGER time_stamp); 93 void PrintTimeStamp(LARGE_INTEGER time_stamp);
121 void PrintEventContext(const EVENT_TRACE* event, 94 void PrintEventContext(const EVENT_TRACE* event,
122 const base::StringPiece& level, 95 const base::StringPiece& level,
123 const base::StringPiece& context); 96 const base::StringPiece& context);
124 void PrintBadEvent(const EVENT_TRACE* event, const base::StringPiece& error); 97 void PrintBadEvent(const EVENT_TRACE* event, const base::StringPiece& error);
125 98
126 std::ostream* out_; 99 std::ostream* out_;
127 DISALLOW_COPY_AND_ASSIGN(EventPrinter); 100 DISALLOW_COPY_AND_ASSIGN(EventPrinter);
128 }; 101 };
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 const base::StringPiece& file, 191 const base::StringPiece& file,
219 const base::StringPiece& message) { 192 const base::StringPiece& message) {
220 std::ostringstream level_stream; 193 std::ostringstream level_stream;
221 std::ostringstream location_stream; 194 std::ostringstream location_stream;
222 WriteSeverityToStream(severity, &level_stream); 195 WriteSeverityToStream(severity, &level_stream);
223 WriteLocationToStream(file, line, &location_stream); 196 WriteLocationToStream(file, line, &location_stream);
224 PrintEventContext(event, level_stream.str(), location_stream.str()); 197 PrintEventContext(event, level_stream.str(), location_stream.str());
225 *out_ << message << std::endl; 198 *out_ << message << std::endl;
226 } 199 }
227 200
228 void EventPrinter::OnTraceEvent(const EVENT_TRACE* event,
229 const base::StringPiece& name,
230 char type,
231 intptr_t id,
232 const base::StringPiece& extra,
233 DWORD stack_depth,
234 const intptr_t* backtrace) {
235 PrintEventContext(event, GetTraceTypeString(type), base::StringPiece());
236 *out_ << name << " (id=0x" << std::hex << id << std::dec << ") " << extra
237 << std::endl;
238 }
239
240 } // namespace 201 } // namespace
241 202
242 void logging_win::PrintLogFile(const base::FilePath& log_file, 203 void logging_win::PrintLogFile(const base::FilePath& log_file,
243 std::ostream* out) { 204 std::ostream* out) {
244 EventPrinter printer(out); 205 EventPrinter printer(out);
245 logging_win::ReadLogFile(log_file, &printer); 206 logging_win::ReadLogFile(log_file, &printer);
246 } 207 }
OLDNEW
« no previous file with comments | « chrome/test/logging/win/file_logger.cc ('k') | chrome/test/logging/win/log_file_reader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698