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

Side by Side Diff: pkg/analyzer/lib/instrumentation/instrumentation.dart

Issue 818733006: Fix for issue 21982 (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/element.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 27 matching lines...) Expand all
38 * The interface used by client code to communicate with an instrumentation 38 * The interface used by client code to communicate with an instrumentation
39 * server by wrapping an [InstrumentationServer]. 39 * server by wrapping an [InstrumentationServer].
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_EXCEPTION = 'Ex'; 49 static const String TAG_EXCEPTION = 'Ex';
49 static const String TAG_NOTIFICATION = 'Noti'; 50 static const String TAG_NOTIFICATION = 'Noti';
50 static const String TAG_REQUEST = 'Req'; 51 static const String TAG_REQUEST = 'Req';
51 static const String TAG_RESPONSE = 'Res'; 52 static const String TAG_RESPONSE = 'Res';
52 static const String TAG_VERSION = 'Ver'; 53 static const String TAG_VERSION = 'Ver';
53 54
54 /** 55 /**
55 * The instrumentation server used to communicate with the server, or `null` 56 * The instrumentation server used to communicate with the server, or `null`
56 * if instrumentation data should not be logged. 57 * if instrumentation data should not be logged.
57 */ 58 */
58 InstrumentationServer _instrumentationServer; 59 InstrumentationServer _instrumentationServer;
59 60
60 /** 61 /**
61 * Initialize a newly created instrumentation service to comunicate with the 62 * Initialize a newly created instrumentation service to comunicate with the
62 * given [instrumentationServer]. 63 * given [instrumentationServer].
63 */ 64 */
64 InstrumentationService(this._instrumentationServer); 65 InstrumentationService(this._instrumentationServer);
65 66
66 /** 67 /**
67 * The current time, expressed as a decimal encoded number of milliseconds. 68 * The current time, expressed as a decimal encoded number of milliseconds.
68 */ 69 */
69 String get _timestamp => new DateTime.now().millisecondsSinceEpoch.toString(); 70 String get _timestamp => new DateTime.now().millisecondsSinceEpoch.toString();
70 71
71 /** 72 /**
73 * Log the fact that an error, described by the given [message], has occurred.
74 */
75 void logError(String message) {
76 _log(TAG_ERROR, message);
77 }
78
79 /**
72 * Log that the given non-priority [exception] was thrown, with the given 80 * Log that the given non-priority [exception] was thrown, with the given
73 * [stackTrace]. 81 * [stackTrace].
74 */ 82 */
75 void logException(dynamic exception, StackTrace stackTrace) { 83 void logException(dynamic exception, StackTrace stackTrace) {
76 if (_instrumentationServer != null) { 84 if (_instrumentationServer != null) {
77 String message = _toString(exception); 85 String message = _toString(exception);
78 String trace = _toString(stackTrace); 86 String trace = _toString(stackTrace);
79 _instrumentationServer.log('$_timestamp:$TAG_EXCEPTION:$message:$trace'); 87 _instrumentationServer.log('$_timestamp:$TAG_EXCEPTION:$message:$trace');
80 } 88 }
81 } 89 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 /** 146 /**
139 * Convert the given [object] to a string. 147 * Convert the given [object] to a string.
140 */ 148 */
141 String _toString(Object object) { 149 String _toString(Object object) {
142 if (object == null) { 150 if (object == null) {
143 return 'null'; 151 return 'null';
144 } 152 }
145 return object.toString(); 153 return object.toString();
146 } 154 }
147 } 155 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/element.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698