| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 * The current time, expressed as a decimal encoded number of milliseconds. | 87 * The current time, expressed as a decimal encoded number of milliseconds. |
| 88 */ | 88 */ |
| 89 String get _timestamp => new DateTime.now().millisecondsSinceEpoch.toString(); | 89 String get _timestamp => new DateTime.now().millisecondsSinceEpoch.toString(); |
| 90 | 90 |
| 91 /** | 91 /** |
| 92 * Log that an analysis task is being performed in the given [context]. The | 92 * Log that an analysis task is being performed in the given [context]. The |
| 93 * task has the given [description]. | 93 * task has the given [description]. |
| 94 */ | 94 */ |
| 95 void logAnalysisTask(String context, String description) { | 95 void logAnalysisTask(String context, String description) { |
| 96 if (_instrumentationServer != null) { | 96 if (_instrumentationServer != null) { |
| 97 _instrumentationServer.log( | 97 _instrumentationServer |
| 98 _join([TAG_ANALYSIS_TASK, context, description])); | 98 .log(_join([TAG_ANALYSIS_TASK, context, description])); |
| 99 } | 99 } |
| 100 } | 100 } |
| 101 | 101 |
| 102 /** | 102 /** |
| 103 * Log the fact that an error, described by the given [message], has occurred. | 103 * Log the fact that an error, described by the given [message], has occurred. |
| 104 */ | 104 */ |
| 105 void logError(String message) { | 105 void logError(String message) { |
| 106 _log(TAG_ERROR, message); | 106 _log(TAG_ERROR, message); |
| 107 } | 107 } |
| 108 | 108 |
| 109 /** | 109 /** |
| 110 * Log that the given non-priority [exception] was thrown, with the given | 110 * Log that the given non-priority [exception] was thrown, with the given |
| 111 * [stackTrace]. | 111 * [stackTrace]. |
| 112 */ | 112 */ |
| 113 void logException(dynamic exception, StackTrace stackTrace) { | 113 void logException(dynamic exception, StackTrace stackTrace) { |
| 114 if (_instrumentationServer != null) { | 114 if (_instrumentationServer != null) { |
| 115 String message = _toString(exception); | 115 String message = _toString(exception); |
| 116 String trace = _toString(stackTrace); | 116 String trace = _toString(stackTrace); |
| 117 _instrumentationServer.log(_join([TAG_EXCEPTION, message, trace])); | 117 _instrumentationServer.log(_join([TAG_EXCEPTION, message, trace])); |
| 118 } | 118 } |
| 119 } | 119 } |
| 120 | 120 |
| 121 /** | 121 /** |
| 122 * Log that the contents of the file with the given [path] were read. The file | 122 * Log that the contents of the file with the given [path] were read. The file |
| 123 * had the given [content] and [modificationTime]. | 123 * had the given [content] and [modificationTime]. |
| 124 */ | 124 */ |
| 125 void logFileRead(String path, int modificationTime, String content) { | 125 void logFileRead(String path, int modificationTime, String content) { |
| 126 if (_instrumentationServer != null) { | 126 if (_instrumentationServer != null) { |
| 127 String timeStamp = _toString(modificationTime); | 127 String timeStamp = _toString(modificationTime); |
| 128 _instrumentationServer.log( | 128 _instrumentationServer |
| 129 _join([TAG_FILE_READ, path, timeStamp, content])); | 129 .log(_join([TAG_FILE_READ, path, timeStamp, content])); |
| 130 } | 130 } |
| 131 } | 131 } |
| 132 | 132 |
| 133 /** | 133 /** |
| 134 * Log that a log entry that was written to the analysis engine's log. The log | 134 * Log that a log entry that was written to the analysis engine's log. The log |
| 135 * entry has the given [level] and [message], and was created at the given | 135 * entry has the given [level] and [message], and was created at the given |
| 136 * [time]. | 136 * [time]. |
| 137 */ | 137 */ |
| 138 void logLogEntry(String level, DateTime time, String message) { | 138 void logLogEntry(String level, DateTime time, String message) { |
| 139 if (_instrumentationServer != null) { | 139 if (_instrumentationServer != null) { |
| 140 String timeStamp = | 140 String timeStamp = |
| 141 time == null ? 'null' : time.millisecondsSinceEpoch.toString(); | 141 time == null ? 'null' : time.millisecondsSinceEpoch.toString(); |
| 142 _instrumentationServer.log( | 142 _instrumentationServer |
| 143 _join([TAG_LOG_ENTRY, level, timeStamp, message])); | 143 .log(_join([TAG_LOG_ENTRY, level, timeStamp, message])); |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 | 146 |
| 147 /** | 147 /** |
| 148 * Log that a notification has been sent to the client. | 148 * Log that a notification has been sent to the client. |
| 149 */ | 149 */ |
| 150 void logNotification(String notification) { | 150 void logNotification(String notification) { |
| 151 _log(TAG_NOTIFICATION, notification); | 151 _log(TAG_NOTIFICATION, notification); |
| 152 } | 152 } |
| 153 | 153 |
| 154 /** | 154 /** |
| 155 * Log the given performance fact. | 155 * Log the given performance fact. |
| 156 */ | 156 */ |
| 157 void logPerformance(String kind, Stopwatch sw, String message) { | 157 void logPerformance(String kind, Stopwatch sw, String message) { |
| 158 sw.stop(); | 158 sw.stop(); |
| 159 String elapsed = sw.elapsedMilliseconds.toString(); | 159 String elapsed = sw.elapsedMilliseconds.toString(); |
| 160 if (_instrumentationServer != null) { | 160 if (_instrumentationServer != null) { |
| 161 _instrumentationServer.log( | 161 _instrumentationServer |
| 162 _join([TAG_PERFORMANCE, kind, elapsed, message])); | 162 .log(_join([TAG_PERFORMANCE, kind, elapsed, message])); |
| 163 } | 163 } |
| 164 } | 164 } |
| 165 | 165 |
| 166 /** | 166 /** |
| 167 * Log that the given priority [exception] was thrown, with the given | 167 * Log that the given priority [exception] was thrown, with the given |
| 168 * [stackTrace]. | 168 * [stackTrace]. |
| 169 */ | 169 */ |
| 170 void logPriorityException(dynamic exception, StackTrace stackTrace) { | 170 void logPriorityException(dynamic exception, StackTrace stackTrace) { |
| 171 if (_instrumentationServer != null) { | 171 if (_instrumentationServer != null) { |
| 172 String message = _toString(exception); | 172 String message = _toString(exception); |
| 173 String trace = _toString(stackTrace); | 173 String trace = _toString(stackTrace); |
| 174 _instrumentationServer.logWithPriority( | 174 _instrumentationServer |
| 175 _join([TAG_EXCEPTION, message, trace])); | 175 .logWithPriority(_join([TAG_EXCEPTION, message, trace])); |
| 176 } | 176 } |
| 177 } | 177 } |
| 178 | 178 |
| 179 /** | 179 /** |
| 180 * Log that a request has been sent to the client. | 180 * Log that a request has been sent to the client. |
| 181 */ | 181 */ |
| 182 void logRequest(String request) { | 182 void logRequest(String request) { |
| 183 _log(TAG_REQUEST, request); | 183 _log(TAG_REQUEST, request); |
| 184 } | 184 } |
| 185 | 185 |
| 186 /** | 186 /** |
| 187 * Log that a response has been sent to the client. | 187 * Log that a response has been sent to the client. |
| 188 */ | 188 */ |
| 189 void logResponse(String response) { | 189 void logResponse(String response) { |
| 190 _log(TAG_RESPONSE, response); | 190 _log(TAG_RESPONSE, response); |
| 191 } | 191 } |
| 192 | 192 |
| 193 /** | 193 /** |
| 194 * Signal that the client has started analysis server. | 194 * Signal that the client has started analysis server. |
| 195 * This method should be invoked exactly one time. | 195 * This method should be invoked exactly one time. |
| 196 */ | 196 */ |
| 197 void logVersion(String uuid, String clientId, String clientVersion, | 197 void logVersion(String uuid, String clientId, String clientVersion, |
| 198 String serverVersion, String sdkVersion) { | 198 String serverVersion, String sdkVersion) { |
| 199 | |
| 200 String normalize(String value) => | 199 String normalize(String value) => |
| 201 value != null && value.length > 0 ? value : 'unknown'; | 200 value != null && value.length > 0 ? value : 'unknown'; |
| 202 | 201 |
| 203 if (_instrumentationServer != null) { | 202 if (_instrumentationServer != null) { |
| 204 _instrumentationServer.logWithPriority( | 203 _instrumentationServer.logWithPriority(_join([ |
| 205 _join( | 204 TAG_VERSION, |
| 206 [ | 205 uuid, |
| 207 TAG_VERSION, | 206 normalize(clientId), |
| 208 uuid, | 207 normalize(clientVersion), |
| 209 normalize(clientId), | 208 serverVersion, |
| 210 normalize(clientVersion), | 209 sdkVersion |
| 211 serverVersion, | 210 ])); |
| 212 sdkVersion])); | |
| 213 } | 211 } |
| 214 } | 212 } |
| 215 | 213 |
| 216 /** | 214 /** |
| 217 * Log that the file system watcher sent an event. The [folderPath] is the | 215 * Log that the file system watcher sent an event. The [folderPath] is the |
| 218 * path to the folder containing the changed file, the [filePath] is the path | 216 * path to the folder containing the changed file, the [filePath] is the path |
| 219 * of the file that changed, and the [changeType] indicates what kind of | 217 * of the file that changed, and the [changeType] indicates what kind of |
| 220 * change occurred. | 218 * change occurred. |
| 221 */ | 219 */ |
| 222 void logWatchEvent(String folderPath, String filePath, String changeType) { | 220 void logWatchEvent(String folderPath, String filePath, String changeType) { |
| 223 if (_instrumentationServer != null) { | 221 if (_instrumentationServer != null) { |
| 224 _instrumentationServer.log( | 222 _instrumentationServer |
| 225 _join([TAG_WATCH_EVENT, folderPath, filePath, changeType])); | 223 .log(_join([TAG_WATCH_EVENT, folderPath, filePath, changeType])); |
| 226 } | 224 } |
| 227 } | 225 } |
| 228 | 226 |
| 229 /** | 227 /** |
| 230 * Signal that the client is done communicating with the instrumentation | 228 * Signal that the client is done communicating with the instrumentation |
| 231 * server. This method should be invoked exactly one time and no other methods | 229 * server. This method should be invoked exactly one time and no other methods |
| 232 * should be invoked on this instance after this method has been invoked. | 230 * should be invoked on this instance after this method has been invoked. |
| 233 */ | 231 */ |
| 234 void shutdown() { | 232 void shutdown() { |
| 235 if (_instrumentationServer != null) { | 233 if (_instrumentationServer != null) { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 } | 311 } |
| 314 } | 312 } |
| 315 | 313 |
| 316 @override | 314 @override |
| 317 void shutdown() { | 315 void shutdown() { |
| 318 for (InstrumentationServer server in _servers) { | 316 for (InstrumentationServer server in _servers) { |
| 319 server.shutdown(); | 317 server.shutdown(); |
| 320 } | 318 } |
| 321 } | 319 } |
| 322 } | 320 } |
| OLD | NEW |