Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
| 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. | |
| 4 | |
| 5 library barback.barback_logger; | |
| 6 | |
| 7 import 'package:source_maps/span.dart'; | |
| 8 | |
| 9 import 'asset_id.dart'; | |
| 10 import 'errors.dart'; | |
| 11 | |
| 12 /// Object used to report warnings and errors encountered while running a | |
| 13 /// transformer. | |
| 14 class BarbackLogger { | |
| 15 /// Logs [entry]. | |
| 16 void logEntry(LogEntry entry) { | |
|
nweiz
2013/10/16 19:41:27
I'd rather just call this "log". "logEntry" reads
Bob Nystrom
2013/10/28 23:45:56
In pub, we import log.dart with a "log" prefix, so
nweiz
2013/10/29 00:40:13
Does it actually cause a conflict to define a meth
Bob Nystrom
2013/10/29 18:29:45
It doesn't conflict, it wins. So you have to do "t
| |
| 17 var buffer = new StringBuffer(); | |
| 18 buffer.write("[${entry.level} ${entry.transform}] "); | |
| 19 | |
| 20 var message = entry.message; | |
|
nweiz
2013/10/16 19:41:27
Unused variable.
Bob Nystrom
2013/10/28 23:45:56
Done.
| |
| 21 if (entry.span == null) { | |
|
nweiz
2013/10/16 19:41:27
!=
Bob Nystrom
2013/10/28 23:45:56
Eek. Done.
| |
| 22 buffer.write(entry.span.getLocationMessage(entry.message)); | |
| 23 } else { | |
| 24 buffer.write(message); | |
| 25 } | |
| 26 | |
| 27 print(buffer); | |
| 28 } | |
| 29 } | |
| 30 | |
| 31 /// The severity of a logged message. | |
| 32 class LogLevel { | |
|
nweiz
2013/10/16 19:41:27
Do we want to have a FINE level as well?
Bob Nystrom
2013/10/28 23:45:56
Sure, I just added the ones I needed for dart2js,
| |
| 33 static const INFO = const LogLevel("Info"); | |
| 34 static const WARNING = const LogLevel("Warning"); | |
| 35 static const ERROR = const LogLevel("Error"); | |
| 36 | |
| 37 final String name; | |
| 38 const LogLevel(this.name); | |
| 39 | |
| 40 String toString() => name; | |
| 41 } | |
| 42 | |
| 43 /// One message logged during a transform. | |
| 44 class LogEntry { | |
| 45 /// The transform that logged the message. | |
| 46 final TransformInfo transform; | |
| 47 | |
| 48 /// The asset that the message is associated with. | |
| 49 final AssetId asset; | |
|
nweiz
2013/10/16 19:41:27
I'd call this "assetId", since Asset is a differen
Bob Nystrom
2013/10/28 23:45:56
Done.
| |
| 50 | |
| 51 final LogLevel level; | |
| 52 final String message; | |
| 53 | |
| 54 /// The location that the message pertains to or null if not associated with | |
| 55 /// a source [Span]. | |
| 56 final Span span; | |
| 57 | |
| 58 LogEntry(this.transform, this.asset, this.level, this.message, this.span); | |
| 59 } | |
| OLD | NEW |