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

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

Issue 840553004: Capture log messages via instrumentation (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
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 29 matching lines...) Expand all
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_LOG_ENTRY = 'Log';
50 static const String TAG_NOTIFICATION = 'Noti'; 51 static const String TAG_NOTIFICATION = 'Noti';
51 static const String TAG_REQUEST = 'Req'; 52 static const String TAG_REQUEST = 'Req';
52 static const String TAG_RESPONSE = 'Res'; 53 static const String TAG_RESPONSE = 'Res';
53 static const String TAG_VERSION = 'Ver'; 54 static const String TAG_VERSION = 'Ver';
54 55
55 /** 56 /**
56 * The instrumentation server used to communicate with the server, or `null` 57 * The instrumentation server used to communicate with the server, or `null`
57 * if instrumentation data should not be logged. 58 * if instrumentation data should not be logged.
58 */ 59 */
59 InstrumentationServer _instrumentationServer; 60 InstrumentationServer _instrumentationServer;
(...skipping 22 matching lines...) Expand all
82 */ 83 */
83 void logException(dynamic exception, StackTrace stackTrace) { 84 void logException(dynamic exception, StackTrace stackTrace) {
84 if (_instrumentationServer != null) { 85 if (_instrumentationServer != null) {
85 String message = _toString(exception); 86 String message = _toString(exception);
86 String trace = _toString(stackTrace); 87 String trace = _toString(stackTrace);
87 _instrumentationServer.log(_join([TAG_EXCEPTION, message, trace])); 88 _instrumentationServer.log(_join([TAG_EXCEPTION, message, trace]));
88 } 89 }
89 } 90 }
90 91
91 /** 92 /**
93 * Log a log entry that was written to the analysis engine's log.
94 */
95 void logLogEntry(String level, DateTime time, String message) {
96 if (_instrumentationServer != null) {
97 String timeStamp = _toString(time);
98 _instrumentationServer.log(
99 _join([TAG_LOG_ENTRY, level, timeStamp, message]));
100 }
101 }
102
103 /**
92 * Log that a notification has been sent to the client. 104 * Log that a notification has been sent to the client.
93 */ 105 */
94 void logNotification(String notification) { 106 void logNotification(String notification) {
95 _log(TAG_NOTIFICATION, notification); 107 _log(TAG_NOTIFICATION, notification);
96 } 108 }
97 109
98 /** 110 /**
99 * Log that the given priority [exception] was thrown, with the given 111 * Log that the given priority [exception] was thrown, with the given
100 * [stackTrace]. 112 * [stackTrace].
101 */ 113 */
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 } 221 }
210 } 222 }
211 223
212 @override 224 @override
213 void shutdown() { 225 void shutdown() {
214 for (InstrumentationServer server in _servers) { 226 for (InstrumentationServer server in _servers) {
215 server.shutdown(); 227 server.shutdown();
216 } 228 }
217 } 229 }
218 } 230 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698