Chromium Code Reviews| Index: pkg/analyzer/lib/instrumentation/instrumentation.dart |
| diff --git a/pkg/analyzer/lib/instrumentation/instrumentation.dart b/pkg/analyzer/lib/instrumentation/instrumentation.dart |
| index f435fab6562de41b779a173aed596c467a65bbe6..6a7d6272f0eca61e6c88fef7ad02c850a2a11562 100644 |
| --- a/pkg/analyzer/lib/instrumentation/instrumentation.dart |
| +++ b/pkg/analyzer/lib/instrumentation/instrumentation.dart |
| @@ -45,6 +45,7 @@ class InstrumentationService { |
| static final InstrumentationService NULL_SERVICE = |
| new InstrumentationService(null); |
| + static const String TAG_EXCEPTION = 'Ex'; |
| static const String TAG_NOTIFICATION = 'Noti'; |
| static const String TAG_REQUEST = 'Req'; |
| static const String TAG_RESPONSE = 'Res'; |
| @@ -65,7 +66,19 @@ class InstrumentationService { |
| /** |
| * The current time, expressed as a decimal encoded number of milliseconds. |
| */ |
| - String get _timestamp => new DateTime.now().millisecond.toString(); |
| + String get _timestamp => new DateTime.now().millisecondsSinceEpoch.toString(); |
| + |
| + /** |
| + * Log that the given [exception] was thrown, with the given [stackTrace]. |
| + */ |
| + void logException(dynamic exception, StackTrace stackTrace) { |
| + if (_instrumentationServer != null) { |
| + String message = _toString(exception); |
| + String trace = _toString(stackTrace); |
| + _instrumentationServer.logWithPriority( |
| + '$_timestamp:$TAG_EXCEPTION:$message:$trace'); |
|
Paul Berry
2014/12/19 17:07:51
Should "$message" be escaped in any way to make it
Brian Wilkerson
2014/12/19 17:10:47
Good question. I thought about other special chara
|
| + } |
| + } |
| /** |
| * Log that a notification has been sent to the client. |
| @@ -108,4 +121,14 @@ class InstrumentationService { |
| _instrumentationServer.log('$_timestamp:$tag:$message'); |
| } |
| } |
| + |
| + /** |
| + * Convert the given [object] to a string. |
| + */ |
| + String _toString(Object object) { |
| + if (object == null) { |
| + return 'null'; |
| + } |
| + return object.toString(); |
| + } |
| } |