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

Unified Diff: pkg/analyzer/lib/instrumentation/instrumentation.dart

Issue 797503004: Instrument top-level exceptions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analysis_server/lib/driver.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
+ }
}
« no previous file with comments | « pkg/analysis_server/lib/driver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698