OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 /// Message logging. | 5 /// Message logging. |
6 library pub.log; | 6 library pub.log; |
7 | 7 |
8 import 'dart:async'; | 8 import 'dart:async'; |
9 import 'dart:convert'; | 9 import 'dart:convert'; |
10 import 'dart:io'; | 10 import 'dart:io'; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 /// Silence all logging. | 104 /// Silence all logging. |
105 static const NONE = const Verbosity._("none", const { | 105 static const NONE = const Verbosity._("none", const { |
106 Level.ERROR: null, | 106 Level.ERROR: null, |
107 Level.WARNING: null, | 107 Level.WARNING: null, |
108 Level.MESSAGE: null, | 108 Level.MESSAGE: null, |
109 Level.IO: null, | 109 Level.IO: null, |
110 Level.SOLVER: null, | 110 Level.SOLVER: null, |
111 Level.FINE: null | 111 Level.FINE: null |
112 }); | 112 }); |
113 | 113 |
| 114 /// Shows only errors. |
| 115 static const ERROR = const Verbosity._("error", const { |
| 116 Level.ERROR: _logToStderr, |
| 117 Level.WARNING: null, |
| 118 Level.MESSAGE: null, |
| 119 Level.IO: null, |
| 120 Level.SOLVER: null, |
| 121 Level.FINE: null |
| 122 }); |
| 123 |
114 /// Shows only errors and warnings. | 124 /// Shows only errors and warnings. |
115 static const WARNING = const Verbosity._("warning", const { | 125 static const WARNING = const Verbosity._("warning", const { |
116 Level.ERROR: _logToStderr, | 126 Level.ERROR: _logToStderr, |
117 Level.WARNING: _logToStderr, | 127 Level.WARNING: _logToStderr, |
118 Level.MESSAGE: null, | 128 Level.MESSAGE: null, |
119 Level.IO: null, | 129 Level.IO: null, |
120 Level.SOLVER: null, | 130 Level.SOLVER: null, |
121 Level.FINE: null | 131 Level.FINE: null |
122 }); | 132 }); |
123 | 133 |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 this.message(errorJson); | 548 this.message(errorJson); |
539 } | 549 } |
540 | 550 |
541 /// Encodes [message] to JSON and prints it if JSON output is enabled. | 551 /// Encodes [message] to JSON and prints it if JSON output is enabled. |
542 void message(message) { | 552 void message(message) { |
543 if (!enabled) return; | 553 if (!enabled) return; |
544 | 554 |
545 print(JSON.encode(message)); | 555 print(JSON.encode(message)); |
546 } | 556 } |
547 } | 557 } |
OLD | NEW |