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

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

Issue 259773005: New analyzer snapshot. Sorted unit members. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.instrumentation; 8 library engine.instrumentation;
9 9
10 import 'java_core.dart'; 10 import 'java_core.dart';
11 11
12 /** 12 /**
13 * The interface `InstrumentationLogger` defines the behavior of objects that ar e used to log 13 * The class `Instrumentation` implements support for logging instrumentation in formation.
14 * instrumentation data.
15 * 14 *
16 * For an example of using objects that implement this interface, see [Instrumen tation]. 15 * Instrumentation information consists of information about specific operations . Those operations
16 * can range from user-facing operations, such as saving the changes to a file, to internal
17 * operations, such as tokenizing source code. The information to be logged is g athered by
18 * [InstrumentationBuilder], created by one of the static methods on
19 * this class such as [builder] or [builder].
20 *
21 * Note, however, that until an instrumentation logger is installed using the me thod
22 * [setLogger], all instrumentation data will be lost.
23 *
24 * <b>Example</b>
25 *
26 * To collect metrics about how long it took to save a file, you would write som ething like the
27 * following:
28 *
29 * <pre>
30 * InstrumentationBuilder instrumentation = Instrumentation.builder(this.getClas s());
31 * // save the file
32 * instrumentation.metric("chars", fileLength).log();
33 * </pre>
34 * The `Instrumentation.builder` method creates a new [InstrumentationBuilder
35 ] and records the time at which it was created. The
36 * [InstrumentationBuilder#metric] appends the information specified by the
37 * arguments and records the time at which the method is called so that the time to complete the
38 * save operation can be calculated. The `log` method tells the builder that all of the data
39 * has been collected and that the resulting information should be logged.
17 */ 40 */
18 abstract class InstrumentationLogger { 41 class Instrumentation {
19 /** 42 /**
20 * Create a builder that can collect the data associated with an operation ide ntified by the given 43 * A builder that will silently ignore all data and logging requests.
21 * name. 44 */
45 static InstrumentationBuilder _NULL_INSTRUMENTATION_BUILDER = new Instrumentat ionBuilder_Instrumentation_NULL_INSTRUMENTATION_BUILDER();
46
47 /**
48 * An instrumentation logger that can be used when no other instrumentation lo gger has been
49 * configured. This logger will silently ignore all data and logging requests.
50 */
51 static InstrumentationLogger _NULL_LOGGER = new InstrumentationLogger_Instrume ntation_NULL_LOGGER();
52
53 /**
54 * The current instrumentation logger.
55 */
56 static InstrumentationLogger _CURRENT_LOGGER = _NULL_LOGGER;
57
58 /**
59 * Create a builder that can collect the data associated with an operation.
22 * 60 *
23 * @param name the name used to uniquely identify the operation 61 * @param clazz the class performing the operation (not `null`)
24 * @return the builder that was created 62 * @return the builder that was created (not `null`)
25 */ 63 */
26 InstrumentationBuilder createBuilder(String name); 64 static InstrumentationBuilder builder(Type clazz) => _CURRENT_LOGGER.createBui lder(clazz.toString());
65
66 /**
67 * Create a builder that can collect the data associated with an operation.
68 *
69 * @param name the name used to uniquely identify the operation (not `null`)
70 * @return the builder that was created (not `null`)
71 */
72 static InstrumentationBuilder builder2(String name) => _CURRENT_LOGGER.createB uilder(name);
73
74 /**
75 * Get the currently active instrumentation logger
76 */
77 static InstrumentationLogger get logger => _CURRENT_LOGGER;
78
79 /**
80 * Return a builder that will silently ignore all data and logging requests.
81 *
82 * @return the builder (not `null`)
83 */
84 static InstrumentationBuilder get nullBuilder => _NULL_INSTRUMENTATION_BUILDER ;
85
86 /**
87 * Is this instrumentation system currently configured to drop instrumentation data provided to
88 * it?
89 *
90 * @return
91 */
92 static bool get isNullLogger => identical(_CURRENT_LOGGER, _NULL_LOGGER);
93
94 /**
95 * Set the logger that should receive instrumentation information to the given logger.
96 *
97 * @param logger the logger that should receive instrumentation information
98 */
99 static void set logger(InstrumentationLogger logger) {
100 _CURRENT_LOGGER = logger == null ? _NULL_LOGGER : logger;
101 }
27 } 102 }
28 103
29 /** 104 /**
30 * The instrumentation recording level representing (1) recording [EVERYTHING] r ecording of
31 * all instrumentation data, (2) recording only [METRICS] information, or (3) re cording
32 * turned [OFF] in which case nothing is recorded.
33 */
34 class InstrumentationLevel extends Enum<InstrumentationLevel> {
35 /** Recording all instrumented information */
36 static const InstrumentationLevel EVERYTHING = const InstrumentationLevel('EVE RYTHING', 0);
37
38 /** Recording only metrics */
39 static const InstrumentationLevel METRICS = const InstrumentationLevel('METRIC S', 1);
40
41 /** Nothing recorded */
42 static const InstrumentationLevel OFF = const InstrumentationLevel('OFF', 2);
43
44 static const List<InstrumentationLevel> values = const [EVERYTHING, METRICS, O FF];
45
46 static InstrumentationLevel fromString(String str) {
47 if (str == "EVERYTHING") {
48 return InstrumentationLevel.EVERYTHING;
49 }
50 if (str == "METRICS") {
51 return InstrumentationLevel.METRICS;
52 }
53 if (str == "OFF") {
54 return InstrumentationLevel.OFF;
55 }
56 throw new IllegalArgumentException("Unrecognised InstrumentationLevel");
57 }
58
59 const InstrumentationLevel(String name, int ordinal) : super(name, ordinal);
60 }
61
62 /**
63 * The interface `InstrumentationBuilder` defines the behavior of objects used t o collect data 105 * The interface `InstrumentationBuilder` defines the behavior of objects used t o collect data
64 * about an operation that has occurred and record that data through an instrume ntation logger. 106 * about an operation that has occurred and record that data through an instrume ntation logger.
65 * 107 *
66 * For an example of using objects that implement this interface, see [Instrumen tation]. 108 * For an example of using objects that implement this interface, see [Instrumen tation].
67 */ 109 */
68 abstract class InstrumentationBuilder { 110 abstract class InstrumentationBuilder {
69 /** 111 /**
70 * Append the given data to the data being collected by this builder. The info rmation is declared 112 * Append the given data to the data being collected by this builder. The info rmation is declared
71 * to potentially contain data that is either user identifiable or contains us er intellectual 113 * to potentially contain data that is either user identifiable or contains us er intellectual
72 * property (but is not guaranteed to contain either). 114 * property (but is not guaranteed to contain either).
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 * class name is captured using [metric]. Other aspects of the exception 225 * class name is captured using [metric]. Other aspects of the exception
184 * may contain either user identifiable or contains user intellectual property (but is not 226 * may contain either user identifiable or contains user intellectual property (but is not
185 * guaranteed to contain either) and thus are captured using the various data methods such as 227 * guaranteed to contain either) and thus are captured using the various data methods such as
186 * [data]. 228 * [data].
187 * 229 *
188 * @param exception the exception (may be `null`) 230 * @param exception the exception (may be `null`)
189 */ 231 */
190 InstrumentationBuilder record(Exception exception); 232 InstrumentationBuilder record(Exception exception);
191 } 233 }
192 234
193 /**
194 * The class `Instrumentation` implements support for logging instrumentation in formation.
195 *
196 * Instrumentation information consists of information about specific operations . Those operations
197 * can range from user-facing operations, such as saving the changes to a file, to internal
198 * operations, such as tokenizing source code. The information to be logged is g athered by
199 * [InstrumentationBuilder], created by one of the static methods on
200 * this class such as [builder] or [builder].
201 *
202 * Note, however, that until an instrumentation logger is installed using the me thod
203 * [setLogger], all instrumentation data will be lost.
204 *
205 * <b>Example</b>
206 *
207 * To collect metrics about how long it took to save a file, you would write som ething like the
208 * following:
209 *
210 * <pre>
211 * InstrumentationBuilder instrumentation = Instrumentation.builder(this.getClas s());
212 * // save the file
213 * instrumentation.metric("chars", fileLength).log();
214 * </pre>
215 * The `Instrumentation.builder` method creates a new [InstrumentationBuilder
216 ] and records the time at which it was created. The
217 * [InstrumentationBuilder#metric] appends the information specified by the
218 * arguments and records the time at which the method is called so that the time to complete the
219 * save operation can be calculated. The `log` method tells the builder that all of the data
220 * has been collected and that the resulting information should be logged.
221 */
222 class Instrumentation {
223 /**
224 * A builder that will silently ignore all data and logging requests.
225 */
226 static InstrumentationBuilder _NULL_INSTRUMENTATION_BUILDER = new Instrumentat ionBuilder_Instrumentation_NULL_INSTRUMENTATION_BUILDER();
227
228 /**
229 * An instrumentation logger that can be used when no other instrumentation lo gger has been
230 * configured. This logger will silently ignore all data and logging requests.
231 */
232 static InstrumentationLogger _NULL_LOGGER = new InstrumentationLogger_Instrume ntation_NULL_LOGGER();
233
234 /**
235 * The current instrumentation logger.
236 */
237 static InstrumentationLogger _CURRENT_LOGGER = _NULL_LOGGER;
238
239 /**
240 * Create a builder that can collect the data associated with an operation.
241 *
242 * @param clazz the class performing the operation (not `null`)
243 * @return the builder that was created (not `null`)
244 */
245 static InstrumentationBuilder builder(Type clazz) => _CURRENT_LOGGER.createBui lder(clazz.toString());
246
247 /**
248 * Create a builder that can collect the data associated with an operation.
249 *
250 * @param name the name used to uniquely identify the operation (not `null`)
251 * @return the builder that was created (not `null`)
252 */
253 static InstrumentationBuilder builder2(String name) => _CURRENT_LOGGER.createB uilder(name);
254
255 /**
256 * Get the currently active instrumentation logger
257 */
258 static InstrumentationLogger get logger => _CURRENT_LOGGER;
259
260 /**
261 * Return a builder that will silently ignore all data and logging requests.
262 *
263 * @return the builder (not `null`)
264 */
265 static InstrumentationBuilder get nullBuilder => _NULL_INSTRUMENTATION_BUILDER ;
266
267 /**
268 * Is this instrumentation system currently configured to drop instrumentation data provided to
269 * it?
270 *
271 * @return
272 */
273 static bool get isNullLogger => identical(_CURRENT_LOGGER, _NULL_LOGGER);
274
275 /**
276 * Set the logger that should receive instrumentation information to the given logger.
277 *
278 * @param logger the logger that should receive instrumentation information
279 */
280 static void set logger(InstrumentationLogger logger) {
281 _CURRENT_LOGGER = logger == null ? _NULL_LOGGER : logger;
282 }
283 }
284
285 class InstrumentationBuilder_Instrumentation_NULL_INSTRUMENTATION_BUILDER implem ents InstrumentationBuilder { 235 class InstrumentationBuilder_Instrumentation_NULL_INSTRUMENTATION_BUILDER implem ents InstrumentationBuilder {
286 @override 236 @override
287 InstrumentationBuilder data(String name, bool value) => this; 237 InstrumentationBuilder data(String name, bool value) => this;
288 238
289 @override 239 @override
290 InstrumentationBuilder data2(String name, int value) => this; 240 InstrumentationBuilder data2(String name, int value) => this;
291 241
292 @override 242 @override
293 InstrumentationBuilder data3(String name, String value) => this; 243 InstrumentationBuilder data3(String name, String value) => this;
294 244
(...skipping 20 matching lines...) Expand all
315 @override 265 @override
316 InstrumentationBuilder metric3(String name, String value) => this; 266 InstrumentationBuilder metric3(String name, String value) => this;
317 267
318 @override 268 @override
319 InstrumentationBuilder metric4(String name, List<String> value) => this; 269 InstrumentationBuilder metric4(String name, List<String> value) => this;
320 270
321 @override 271 @override
322 InstrumentationBuilder record(Exception exception) => this; 272 InstrumentationBuilder record(Exception exception) => this;
323 } 273 }
324 274
275 /**
276 * The instrumentation recording level representing (1) recording [EVERYTHING] r ecording of
277 * all instrumentation data, (2) recording only [METRICS] information, or (3) re cording
278 * turned [OFF] in which case nothing is recorded.
279 */
280 class InstrumentationLevel extends Enum<InstrumentationLevel> {
281 /** Recording all instrumented information */
282 static const InstrumentationLevel EVERYTHING = const InstrumentationLevel('EVE RYTHING', 0);
283
284 /** Recording only metrics */
285 static const InstrumentationLevel METRICS = const InstrumentationLevel('METRIC S', 1);
286
287 /** Nothing recorded */
288 static const InstrumentationLevel OFF = const InstrumentationLevel('OFF', 2);
289
290 static const List<InstrumentationLevel> values = const [EVERYTHING, METRICS, O FF];
291
292 static InstrumentationLevel fromString(String str) {
293 if (str == "EVERYTHING") {
294 return InstrumentationLevel.EVERYTHING;
295 }
296 if (str == "METRICS") {
297 return InstrumentationLevel.METRICS;
298 }
299 if (str == "OFF") {
300 return InstrumentationLevel.OFF;
301 }
302 throw new IllegalArgumentException("Unrecognised InstrumentationLevel");
303 }
304
305 const InstrumentationLevel(String name, int ordinal) : super(name, ordinal);
306 }
307
308 /**
309 * The interface `InstrumentationLogger` defines the behavior of objects that ar e used to log
310 * instrumentation data.
311 *
312 * For an example of using objects that implement this interface, see [Instrumen tation].
313 */
314 abstract class InstrumentationLogger {
315 /**
316 * Create a builder that can collect the data associated with an operation ide ntified by the given
317 * name.
318 *
319 * @param name the name used to uniquely identify the operation
320 * @return the builder that was created
321 */
322 InstrumentationBuilder createBuilder(String name);
323 }
324
325 class InstrumentationLogger_Instrumentation_NULL_LOGGER implements Instrumentati onLogger { 325 class InstrumentationLogger_Instrumentation_NULL_LOGGER implements Instrumentati onLogger {
326 @override 326 @override
327 InstrumentationBuilder createBuilder(String name) => Instrumentation._NULL_INS TRUMENTATION_BUILDER; 327 InstrumentationBuilder createBuilder(String name) => Instrumentation._NULL_INS TRUMENTATION_BUILDER;
328 } 328 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/index.dart ('k') | pkg/analyzer/lib/src/generated/java_core.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698