OLD | NEW |
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:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 import 'dart:math' show min; | 9 import 'dart:math' show min; |
10 import 'dart:convert'; | 10 import 'dart:convert'; |
(...skipping 17 matching lines...) Expand all Loading... |
28 if (_sink != null) { | 28 if (_sink != null) { |
29 _sink.close(); | 29 _sink.close(); |
30 _sink = null; | 30 _sink = null; |
31 } | 31 } |
32 } | 32 } |
33 | 33 |
34 static String _formatErrorMessage(String msg, error) { | 34 static String _formatErrorMessage(String msg, error) { |
35 if (error == null) return msg; | 35 if (error == null) return msg; |
36 msg += ": $error"; | 36 msg += ": $error"; |
37 // TODO(floitsch): once the dart-executable that is bundled | 37 // TODO(floitsch): once the dart-executable that is bundled |
38 // with the Dart sources is updated, uncomment the following | 38 // with the Dart sources is updated, pass a trace parameter too and do: |
39 // lines. | |
40 // var trace = getAttachedStackTrace(error); | |
41 // if (trace != null) msg += "\nStackTrace: $trace"; | 39 // if (trace != null) msg += "\nStackTrace: $trace"; |
42 return msg; | 40 return msg; |
43 } | 41 } |
44 static void info(String msg, [error]) { | 42 static void info(String msg, [error]) { |
45 msg = _formatErrorMessage(msg, error); | 43 msg = _formatErrorMessage(msg, error); |
46 _print("$_datetime Info: $msg"); | 44 _print("$_datetime Info: $msg"); |
47 } | 45 } |
48 | 46 |
49 static void warning(String msg, [error]) { | 47 static void warning(String msg, [error]) { |
50 msg = _formatErrorMessage(msg, error); | 48 msg = _formatErrorMessage(msg, error); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 | 160 |
163 class UniqueObject { | 161 class UniqueObject { |
164 static int _nextId = 1; | 162 static int _nextId = 1; |
165 final int _hashCode; | 163 final int _hashCode; |
166 | 164 |
167 int get hashCode => _hashCode; | 165 int get hashCode => _hashCode; |
168 operator==(other) => other is UniqueObject && _hashCode == other._hashCode; | 166 operator==(other) => other is UniqueObject && _hashCode == other._hashCode; |
169 | 167 |
170 UniqueObject() : _hashCode = ++_nextId; | 168 UniqueObject() : _hashCode = ++_nextId; |
171 } | 169 } |
OLD | NEW |