Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library instrumentation; | 5 library instrumentation; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * A container with analysis performance constants. | 8 * A container with analysis performance constants. |
| 9 */ | 9 */ |
| 10 class AnalysisPerformanceKind { | 10 class AnalysisPerformanceKind { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 */ | 69 */ |
| 70 InstrumentationServer _instrumentationServer; | 70 InstrumentationServer _instrumentationServer; |
| 71 | 71 |
| 72 /** | 72 /** |
| 73 * Initialize a newly created instrumentation service to comunicate with the | 73 * Initialize a newly created instrumentation service to comunicate with the |
| 74 * given [instrumentationServer]. | 74 * given [instrumentationServer]. |
| 75 */ | 75 */ |
| 76 InstrumentationService(this._instrumentationServer); | 76 InstrumentationService(this._instrumentationServer); |
| 77 | 77 |
| 78 /** | 78 /** |
| 79 * Return true if this [InstrumentationService] was initialized with a | |
|
Brian Wilkerson
2015/01/13 22:33:29
nit: "true" --> "`true`", "null" --> "`null`"
Paul Berry
2015/01/14 18:23:03
Done.
| |
| 80 * non-null server (and hence instrumentation is active). | |
| 81 */ | |
| 82 bool get isActive => _instrumentationServer != null; | |
| 83 | |
| 84 /** | |
| 79 * The current time, expressed as a decimal encoded number of milliseconds. | 85 * The current time, expressed as a decimal encoded number of milliseconds. |
| 80 */ | 86 */ |
| 81 String get _timestamp => new DateTime.now().millisecondsSinceEpoch.toString(); | 87 String get _timestamp => new DateTime.now().millisecondsSinceEpoch.toString(); |
| 82 | 88 |
| 83 /** | 89 /** |
| 84 * Log the fact that an error, described by the given [message], has occurred. | 90 * Log the fact that an error, described by the given [message], has occurred. |
| 85 */ | 91 */ |
| 86 void logError(String message) { | 92 void logError(String message) { |
| 87 _log(TAG_ERROR, message); | 93 _log(TAG_ERROR, message); |
| 88 } | 94 } |
| 89 | 95 |
| 90 /** | 96 /** |
| 91 * Log that the given non-priority [exception] was thrown, with the given | 97 * Log that the given non-priority [exception] was thrown, with the given |
| 92 * [stackTrace]. | 98 * [stackTrace]. |
| 93 */ | 99 */ |
| 94 void logException(dynamic exception, StackTrace stackTrace) { | 100 void logException(dynamic exception, StackTrace stackTrace) { |
| 95 if (_instrumentationServer != null) { | 101 if (_instrumentationServer != null) { |
| 96 String message = _toString(exception); | 102 String message = _toString(exception); |
| 97 String trace = _toString(stackTrace); | 103 String trace = _toString(stackTrace); |
| 98 _instrumentationServer.log(_join([TAG_EXCEPTION, message, trace])); | 104 _instrumentationServer.log(_join([TAG_EXCEPTION, message, trace])); |
| 99 } | 105 } |
| 100 } | 106 } |
| 101 | 107 |
| 102 /** | 108 /** |
| 103 * Log that the contents of the file with the given [path] were read. The file | 109 * Log that the contents of the file with the given [path] were read. The file |
| 104 * had the given [content] and [modificationTime]. | 110 * had the given [content] and [modificationTime]. |
| 105 */ | 111 */ |
| 106 void logFileRead(String path, int modificationTime, String content) { | 112 void logFileRead(String path, int modificationTime, String content) { |
| 107 if (_instrumentationServer != null) { | 113 if (_instrumentationServer != null) { |
|
Brian Wilkerson
2015/01/13 22:33:29
We should replace existing tests of this form with
Paul Berry
2015/01/14 18:23:03
Agreed. I'll do a follow-up CL.
| |
| 108 String timeStamp = _toString(modificationTime); | 114 String timeStamp = _toString(modificationTime); |
| 109 _instrumentationServer.log(_join([TAG_FILE_READ, path, timeStamp, content] )); | 115 _instrumentationServer.log( |
| 116 _join([TAG_FILE_READ, path, timeStamp, content])); | |
| 110 } | 117 } |
| 111 } | 118 } |
| 112 | 119 |
| 113 /** | 120 /** |
| 114 * Log that a log entry that was written to the analysis engine's log. The log | 121 * Log that a log entry that was written to the analysis engine's log. The log |
| 115 * entry has the given [level] and [message], and was created at the given | 122 * entry has the given [level] and [message], and was created at the given |
| 116 * [time]. | 123 * [time]. |
| 117 */ | 124 */ |
| 118 void logLogEntry(String level, DateTime time, String message) { | 125 void logLogEntry(String level, DateTime time, String message) { |
| 119 if (_instrumentationServer != null) { | 126 if (_instrumentationServer != null) { |
| 120 String timeStamp = time == null ? 'null' : time.millisecondsSinceEpoch.toS tring(); | 127 String timeStamp = |
| 128 time == null ? 'null' : time.millisecondsSinceEpoch.toString(); | |
| 121 _instrumentationServer.log( | 129 _instrumentationServer.log( |
| 122 _join([TAG_LOG_ENTRY, level, timeStamp, message])); | 130 _join([TAG_LOG_ENTRY, level, timeStamp, message])); |
| 123 } | 131 } |
| 124 } | 132 } |
| 125 | 133 |
| 126 /** | 134 /** |
| 127 * Log that a notification has been sent to the client. | 135 * Log that a notification has been sent to the client. |
| 128 */ | 136 */ |
| 129 void logNotification(String notification) { | 137 void logNotification(String notification) { |
| 130 _log(TAG_NOTIFICATION, notification); | 138 _log(TAG_NOTIFICATION, notification); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 256 } | 264 } |
| 257 } | 265 } |
| 258 | 266 |
| 259 @override | 267 @override |
| 260 void shutdown() { | 268 void shutdown() { |
| 261 for (InstrumentationServer server in _servers) { | 269 for (InstrumentationServer server in _servers) { |
| 262 server.shutdown(); | 270 server.shutdown(); |
| 263 } | 271 } |
| 264 } | 272 } |
| 265 } | 273 } |
| OLD | NEW |