| 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 * The interface used by client code to communicate with an instrumentation | 8 * The interface used by client code to communicate with an instrumentation |
| 9 * server. | 9 * server. |
| 10 */ | 10 */ |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 */ | 40 */ |
| 41 class InstrumentationService { | 41 class InstrumentationService { |
| 42 /** | 42 /** |
| 43 * An instrumentation service that will not log any instrumentation data. | 43 * An instrumentation service that will not log any instrumentation data. |
| 44 */ | 44 */ |
| 45 static final InstrumentationService NULL_SERVICE = | 45 static final InstrumentationService NULL_SERVICE = |
| 46 new InstrumentationService(null); | 46 new InstrumentationService(null); |
| 47 | 47 |
| 48 static const String TAG_ERROR = 'Err'; | 48 static const String TAG_ERROR = 'Err'; |
| 49 static const String TAG_EXCEPTION = 'Ex'; | 49 static const String TAG_EXCEPTION = 'Ex'; |
| 50 static const String TAG_FILE_READ = 'Read'; |
| 50 static const String TAG_LOG_ENTRY = 'Log'; | 51 static const String TAG_LOG_ENTRY = 'Log'; |
| 51 static const String TAG_NOTIFICATION = 'Noti'; | 52 static const String TAG_NOTIFICATION = 'Noti'; |
| 52 static const String TAG_REQUEST = 'Req'; | 53 static const String TAG_REQUEST = 'Req'; |
| 53 static const String TAG_RESPONSE = 'Res'; | 54 static const String TAG_RESPONSE = 'Res'; |
| 54 static const String TAG_VERSION = 'Ver'; | 55 static const String TAG_VERSION = 'Ver'; |
| 55 | 56 |
| 56 /** | 57 /** |
| 57 * The instrumentation server used to communicate with the server, or `null` | 58 * The instrumentation server used to communicate with the server, or `null` |
| 58 * if instrumentation data should not be logged. | 59 * if instrumentation data should not be logged. |
| 59 */ | 60 */ |
| (...skipping 23 matching lines...) Expand all Loading... |
| 83 */ | 84 */ |
| 84 void logException(dynamic exception, StackTrace stackTrace) { | 85 void logException(dynamic exception, StackTrace stackTrace) { |
| 85 if (_instrumentationServer != null) { | 86 if (_instrumentationServer != null) { |
| 86 String message = _toString(exception); | 87 String message = _toString(exception); |
| 87 String trace = _toString(stackTrace); | 88 String trace = _toString(stackTrace); |
| 88 _instrumentationServer.log(_join([TAG_EXCEPTION, message, trace])); | 89 _instrumentationServer.log(_join([TAG_EXCEPTION, message, trace])); |
| 89 } | 90 } |
| 90 } | 91 } |
| 91 | 92 |
| 92 /** | 93 /** |
| 93 * Log a log entry that was written to the analysis engine's log. | 94 * Log that the contents of the file with the given [path] were read. The file |
| 95 * had the given [content] and [modificationTime]. |
| 96 */ |
| 97 void logFileRead(String path, int modificationTime, String content) { |
| 98 if (_instrumentationServer != null) { |
| 99 String timeStamp = _toString(modificationTime); |
| 100 _instrumentationServer.log(_join([TAG_FILE_READ, path, timeStamp, content]
)); |
| 101 } |
| 102 } |
| 103 |
| 104 /** |
| 105 * Log that a log entry that was written to the analysis engine's log. The log |
| 106 * entry has the given [level] and [message], and was created at the given |
| 107 * [time]. |
| 94 */ | 108 */ |
| 95 void logLogEntry(String level, DateTime time, String message) { | 109 void logLogEntry(String level, DateTime time, String message) { |
| 96 if (_instrumentationServer != null) { | 110 if (_instrumentationServer != null) { |
| 97 String timeStamp = _toString(time); | 111 String timeStamp = time == null ? 'null' : time.millisecondsSinceEpoch.toS
tring(); |
| 98 _instrumentationServer.log( | 112 _instrumentationServer.log( |
| 99 _join([TAG_LOG_ENTRY, level, timeStamp, message])); | 113 _join([TAG_LOG_ENTRY, level, timeStamp, message])); |
| 100 } | 114 } |
| 101 } | 115 } |
| 102 | 116 |
| 103 /** | 117 /** |
| 104 * Log that a notification has been sent to the client. | 118 * Log that a notification has been sent to the client. |
| 105 */ | 119 */ |
| 106 void logNotification(String notification) { | 120 void logNotification(String notification) { |
| 107 _log(TAG_NOTIFICATION, notification); | 121 _log(TAG_NOTIFICATION, notification); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 } | 235 } |
| 222 } | 236 } |
| 223 | 237 |
| 224 @override | 238 @override |
| 225 void shutdown() { | 239 void shutdown() { |
| 226 for (InstrumentationServer server in _servers) { | 240 for (InstrumentationServer server in _servers) { |
| 227 server.shutdown(); | 241 server.shutdown(); |
| 228 } | 242 } |
| 229 } | 243 } |
| 230 } | 244 } |
| OLD | NEW |