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

Unified Diff: tools/testing/dart/utils.dart

Issue 11962042: Added DebugLogger to testing scripts. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/testing/dart/test_suite.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/testing/dart/utils.dart
diff --git a/tools/testing/dart/utils.dart b/tools/testing/dart/utils.dart
index 280140c90a51dbdbb5c97ad52d237948159c81dc..7c2bbf7ba1bd338e82079a5e9c4972974de508c7 100644
--- a/tools/testing/dart/utils.dart
+++ b/tools/testing/dart/utils.dart
@@ -4,8 +4,50 @@
library utils;
+import 'dart:io';
import 'dart:utf' as utf;
+class DebugLogger {
+ static OutputStream _stream;
+
+ /**
+ * If [path] was null, the DebugLogger will write messages to stdout.
+ */
+ static init(Path path, {append: false}) {
+ if (path != null) {
+ var mode = append ? FileMode.APPEND : FileMode.WRITE;
+ _stream = new File.fromPath(path).openOutputStream(mode);
+ }
+ }
+
+ static void close() {
+ if (_stream != null) {
+ _stream.close();
+ _stream = null;
+ }
+ }
+
+ static void info(String msg) {
+ _print("Info: $msg");
+ }
+
+ static void warning(String msg) {
+ _print("Warning: $msg");
+ }
+
+ static void error(String msg) {
+ _print("Error: $msg");
+ }
+
+ static void _print(String msg) {
+ if (_stream != null) {
+ _stream.write(encodeUtf8(msg));
+ _stream.write([0x0a]);
+ } else {
+ print(msg);
+ }
+ }
+}
List<int> encodeUtf8(String string) {
return utf.encodeUtf8(string);
« no previous file with comments | « tools/testing/dart/test_suite.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698