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

Unified Diff: pkg/barback/lib/src/barback_logger.dart

Issue 26572010: Improve barback/pub logging. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add missing file. Created 7 years, 2 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
Index: pkg/barback/lib/src/barback_logger.dart
diff --git a/pkg/barback/lib/src/barback_logger.dart b/pkg/barback/lib/src/barback_logger.dart
new file mode 100644
index 0000000000000000000000000000000000000000..c343c594f3e58db342ebf658da7495d53cb29160
--- /dev/null
+++ b/pkg/barback/lib/src/barback_logger.dart
@@ -0,0 +1,59 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library barback.barback_logger;
+
+import 'package:source_maps/span.dart';
+
+import 'asset_id.dart';
+import 'errors.dart';
+
+/// Object used to report warnings and errors encountered while running a
+/// transformer.
+class BarbackLogger {
+ /// Logs [entry].
+ 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
+ var buffer = new StringBuffer();
+ buffer.write("[${entry.level} ${entry.transform}] ");
+
+ var message = entry.message;
nweiz 2013/10/16 19:41:27 Unused variable.
Bob Nystrom 2013/10/28 23:45:56 Done.
+ if (entry.span == null) {
nweiz 2013/10/16 19:41:27 !=
Bob Nystrom 2013/10/28 23:45:56 Eek. Done.
+ buffer.write(entry.span.getLocationMessage(entry.message));
+ } else {
+ buffer.write(message);
+ }
+
+ print(buffer);
+ }
+}
+
+/// The severity of a logged message.
+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,
+ static const INFO = const LogLevel("Info");
+ static const WARNING = const LogLevel("Warning");
+ static const ERROR = const LogLevel("Error");
+
+ final String name;
+ const LogLevel(this.name);
+
+ String toString() => name;
+}
+
+/// One message logged during a transform.
+class LogEntry {
+ /// The transform that logged the message.
+ final TransformInfo transform;
+
+ /// The asset that the message is associated with.
+ 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.
+
+ final LogLevel level;
+ final String message;
+
+ /// The location that the message pertains to or null if not associated with
+ /// a source [Span].
+ final Span span;
+
+ LogEntry(this.transform, this.asset, this.level, this.message, this.span);
+}

Powered by Google App Engine
This is Rietveld 408576698