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

Side by Side Diff: tools/testing/dart/utils.dart

Issue 14113018: Revert changes in tools/testing while the Dart executable can't handle it. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 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 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 utils; 5 library utils;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 import 'dart:async' show getAttachedStackTrace; 8 import 'dart:async';
9 import 'dart:utf' as utf; 9 import 'dart:utf' as utf;
10 10
11 class DebugLogger { 11 class DebugLogger {
12 static IOSink _sink; 12 static IOSink _sink;
13 13
14 /** 14 /**
15 * If [path] was null, the DebugLogger will write messages to stdout. 15 * If [path] was null, the DebugLogger will write messages to stdout.
16 */ 16 */
17 static init(Path path, {append: false}) { 17 static init(Path path, {append: false}) {
18 if (path != null) { 18 if (path != null) {
19 var mode = append ? FileMode.APPEND : FileMode.WRITE; 19 var mode = append ? FileMode.APPEND : FileMode.WRITE;
20 _sink = new File.fromPath(path).openWrite(mode: mode); 20 _sink = new File.fromPath(path).openWrite(mode: mode);
21 } 21 }
22 } 22 }
23 23
24 static void close() { 24 static void close() {
25 if (_sink != null) { 25 if (_sink != null) {
26 _sink.close(); 26 _sink.close();
27 _sink = null; 27 _sink = null;
28 } 28 }
29 } 29 }
30 30
31 static String _formatErrorMessage(String msg, error) { 31 static String _formatErrorMessage(String msg, error) {
32 if (error == null) return msg; 32 if (error == null) return msg;
33 msg += ": $error"; 33 msg += ": $error";
34 var trace = getAttachedStackTrace(error); 34 // TODO(floitsch): once the dart-executable that is bundled
35 if (trace != null) msg += "\nStackTrace: $trace"; 35 // with the Dart sources is updated, uncomment the following
36 // lines.
37 // var trace = getAttachedStackTrace(error);
38 // if (trace != null) msg += "\nStackTrace: $trace";
36 return msg; 39 return msg;
37 } 40 }
38 static void info(String msg, [error]) { 41 static void info(String msg, [error]) {
39 msg = _formatErrorMessage(msg, error); 42 msg = _formatErrorMessage(msg, error);
40 _print("Info: $msg"); 43 _print("Info: $msg");
41 } 44 }
42 45
43 static void warning(String msg, [error]) { 46 static void warning(String msg, [error]) {
44 msg = _formatErrorMessage(msg, error); 47 msg = _formatErrorMessage(msg, error);
45 _print("Warning: $msg"); 48 _print("Warning: $msg");
(...skipping 17 matching lines...) Expand all
63 return utf.encodeUtf8(string); 66 return utf.encodeUtf8(string);
64 } 67 }
65 68
66 // TODO(kustermann,ricow): As soon we have a debug log we should log 69 // TODO(kustermann,ricow): As soon we have a debug log we should log
67 // invalid utf8-encoded input to the log. 70 // invalid utf8-encoded input to the log.
68 // Currently invalid bytes will be replaced by a replacement character. 71 // Currently invalid bytes will be replaced by a replacement character.
69 String decodeUtf8(List<int> bytes) { 72 String decodeUtf8(List<int> bytes) {
70 return utf.decodeUtf8(bytes); 73 return utf.decodeUtf8(bytes);
71 } 74 }
72 75
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698