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

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

Issue 835213002: Escape field separator (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 months 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 | « no previous file | pkg/analyzer/test/instrumentation/instrumentation_test.dart » ('j') | 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 af4f6fc032b0fe8f1f808913621e1b2b43838c56..c2c1b96a28abe5800848c945c8d44e58b7b241fd 100644
--- a/pkg/analyzer/lib/instrumentation/instrumentation.dart
+++ b/pkg/analyzer/lib/instrumentation/instrumentation.dart
@@ -84,7 +84,7 @@ class InstrumentationService {
if (_instrumentationServer != null) {
String message = _toString(exception);
String trace = _toString(stackTrace);
- _instrumentationServer.log('$_timestamp:$TAG_EXCEPTION:$message:$trace');
+ _instrumentationServer.log(_join([TAG_EXCEPTION, message, trace]));
}
}
@@ -104,7 +104,7 @@ class InstrumentationService {
String message = _toString(exception);
String trace = _toString(stackTrace);
_instrumentationServer.logWithPriority(
- '$_timestamp:$TAG_EXCEPTION:$message:$trace');
+ _join([TAG_EXCEPTION, message, trace]));
}
}
@@ -135,11 +135,44 @@ class InstrumentationService {
}
/**
+ * Write an escaped version of the given [string] to the given [buffer].
+ */
+ void _escape(StringBuffer buffer, String field) {
+ int index = field.indexOf(':');
+ if (index < 0) {
+ buffer.write(field);
+ return;
+ }
+ int start = 0;
+ while (index > 0) {
+ buffer.write(field.substring(start, index));
+ buffer.write('::');
+ start = index + 1;
+ index = field.indexOf(':', start);
+ }
+ buffer.write(field.substring(start));
+ }
+
+ /**
+ * Return the result of joining the values of the given fields, escaping the
+ * separator character by doubling it.
+ */
+ String _join(List<String> fields) {
+ StringBuffer buffer = new StringBuffer();
+ buffer.write(_timestamp);
+ for (String field in fields) {
+ buffer.write(':');
+ _escape(buffer, field);
+ }
+ return buffer.toString();
+ }
+
+ /**
* Log the given message with the given tag.
*/
void _log(String tag, String message) {
if (_instrumentationServer != null) {
- _instrumentationServer.log('$_timestamp:$tag:$message');
+ _instrumentationServer.log(_join([tag, message]));
}
}
« no previous file with comments | « no previous file | pkg/analyzer/test/instrumentation/instrumentation_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698