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

Side by Side Diff: utils/pub/log.dart

Issue 13095015: Use backtracking when solving dependency constraints. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise, update to latest corelib, and make backtracker default. 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
OLDNEW
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 log; 6 library log;
7 7
8 import 'dart:io'; 8 import 'dart:io';
9 import 'dart:async'; 9 import 'dart:async';
10 10
(...skipping 19 matching lines...) Expand all
30 /// though possibly in a degraded fashion. 30 /// though possibly in a degraded fashion.
31 static const WARNING = const Level._("WARN"); 31 static const WARNING = const Level._("WARN");
32 32
33 /// A message intended specifically to be shown to the user. 33 /// A message intended specifically to be shown to the user.
34 static const MESSAGE = const Level._("MSG "); 34 static const MESSAGE = const Level._("MSG ");
35 35
36 /// Some interaction with the external world occurred, such as a network 36 /// Some interaction with the external world occurred, such as a network
37 /// operation, process spawning, or file IO. 37 /// operation, process spawning, or file IO.
38 static const IO = const Level._("IO "); 38 static const IO = const Level._("IO ");
39 39
40 /// Incremental output during pub's version constraint solver.
41 static const SOLVER = const Level._("SLVR");
42
40 /// Fine-grained and verbose additional information. Can be used to provide 43 /// Fine-grained and verbose additional information. Can be used to provide
41 /// program state context for other logs (such as what pub was doing when an 44 /// program state context for other logs (such as what pub was doing when an
42 /// IO operation occurred) or just more detail for an operation. 45 /// IO operation occurred) or just more detail for an operation.
43 static const FINE = const Level._("FINE"); 46 static const FINE = const Level._("FINE");
44 47
45 const Level._(this.name); 48 const Level._(this.name);
46 final String name; 49 final String name;
47 50
48 String toString() => name; 51 String toString() => name;
49 int get hashCode => name.hashCode; 52 int get hashCode => name.hashCode;
(...skipping 21 matching lines...) Expand all
71 74
72 /// Logs [message] at [Level.WARNING]. 75 /// Logs [message] at [Level.WARNING].
73 void warning(message) => write(Level.WARNING, message); 76 void warning(message) => write(Level.WARNING, message);
74 77
75 /// Logs [message] at [Level.MESSAGE]. 78 /// Logs [message] at [Level.MESSAGE].
76 void message(message) => write(Level.MESSAGE, message); 79 void message(message) => write(Level.MESSAGE, message);
77 80
78 /// Logs [message] at [Level.IO]. 81 /// Logs [message] at [Level.IO].
79 void io(message) => write(Level.IO, message); 82 void io(message) => write(Level.IO, message);
80 83
84 /// Logs [message] at [Level.SOLVER].
85 void solver(message) => write(Level.SOLVER, message);
86
81 /// Logs [message] at [Level.FINE]. 87 /// Logs [message] at [Level.FINE].
82 void fine(message) => write(Level.FINE, message); 88 void fine(message) => write(Level.FINE, message);
83 89
84 /// Logs [message] at [level]. 90 /// Logs [message] at [level].
85 void write(Level level, message) { 91 void write(Level level, message) {
86 if (_loggers.isEmpty) showNormal(); 92 if (_loggers.isEmpty) showNormal();
87 93
88 var lines = splitLines(message.toString()); 94 var lines = splitLines(message.toString());
89 var entry = new Entry(level, lines); 95 var entry = new Entry(level, lines);
90 96
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 } 177 }
172 stderr.writeln('---- End log transcript ----'); 178 stderr.writeln('---- End log transcript ----');
173 } 179 }
174 180
175 /// Sets the verbosity to "normal", which shows errors, warnings, and messages. 181 /// Sets the verbosity to "normal", which shows errors, warnings, and messages.
176 void showNormal() { 182 void showNormal() {
177 _loggers[Level.ERROR] = _logToStderr; 183 _loggers[Level.ERROR] = _logToStderr;
178 _loggers[Level.WARNING] = _logToStderr; 184 _loggers[Level.WARNING] = _logToStderr;
179 _loggers[Level.MESSAGE] = _logToStdout; 185 _loggers[Level.MESSAGE] = _logToStdout;
180 _loggers[Level.IO] = null; 186 _loggers[Level.IO] = null;
187 _loggers[Level.SOLVER] = null;
181 _loggers[Level.FINE] = null; 188 _loggers[Level.FINE] = null;
182 } 189 }
183 190
184 /// Sets the verbosity to "io", which shows errors, warnings, messages, and IO 191 /// Sets the verbosity to "io", which shows errors, warnings, messages, and IO
185 /// event logs. 192 /// event logs.
186 void showIO() { 193 void showIO() {
187 _loggers[Level.ERROR] = _logToStderrWithLabel; 194 _loggers[Level.ERROR] = _logToStderrWithLabel;
188 _loggers[Level.WARNING] = _logToStderrWithLabel; 195 _loggers[Level.WARNING] = _logToStderrWithLabel;
189 _loggers[Level.MESSAGE] = _logToStdoutWithLabel; 196 _loggers[Level.MESSAGE] = _logToStdoutWithLabel;
190 _loggers[Level.IO] = _logToStderrWithLabel; 197 _loggers[Level.IO] = _logToStderrWithLabel;
198 _loggers[Level.SOLVER] = null;
191 _loggers[Level.FINE] = null; 199 _loggers[Level.FINE] = null;
192 } 200 }
193 201
202 /// Sets the verbosity to "solver", which shows errors, warnings, messages, and
203 /// solver logs.
204 void showSolver() {
205 _loggers[Level.ERROR] = _logToStderr;
206 _loggers[Level.WARNING] = _logToStderr;
207 _loggers[Level.MESSAGE] = _logToStdout;
208 _loggers[Level.IO] = null;
209 _loggers[Level.SOLVER] = _logToStdout;
210 _loggers[Level.FINE] = null;
211 }
212
194 /// Sets the verbosity to "all", which logs ALL the things. 213 /// Sets the verbosity to "all", which logs ALL the things.
195 void showAll() { 214 void showAll() {
196 _loggers[Level.ERROR] = _logToStderrWithLabel; 215 _loggers[Level.ERROR] = _logToStderrWithLabel;
197 _loggers[Level.WARNING] = _logToStderrWithLabel; 216 _loggers[Level.WARNING] = _logToStderrWithLabel;
198 _loggers[Level.MESSAGE] = _logToStdoutWithLabel; 217 _loggers[Level.MESSAGE] = _logToStdoutWithLabel;
199 _loggers[Level.IO] = _logToStderrWithLabel; 218 _loggers[Level.IO] = _logToStderrWithLabel;
219 _loggers[Level.SOLVER] = _logToStderrWithLabel;
200 _loggers[Level.FINE] = _logToStderrWithLabel; 220 _loggers[Level.FINE] = _logToStderrWithLabel;
201 } 221 }
202 222
203 /// Log function that prints the message to stdout. 223 /// Log function that prints the message to stdout.
204 void _logToStdout(Entry entry) { 224 void _logToStdout(Entry entry) {
205 _logToStream(stdout, entry, showLabel: false); 225 _logToStream(stdout, entry, showLabel: false);
206 } 226 }
207 227
208 /// Log function that prints the message to stdout with the level name. 228 /// Log function that prints the message to stdout with the level name.
209 void _logToStdoutWithLabel(Entry entry) { 229 void _logToStdoutWithLabel(Entry entry) {
(...skipping 19 matching lines...) Expand all
229 } else { 249 } else {
230 sink.write(' | '); 250 sink.write(' | ');
231 } 251 }
232 } 252 }
233 253
234 sink.writeln(line); 254 sink.writeln(line);
235 255
236 firstLine = false; 256 firstLine = false;
237 } 257 }
238 } 258 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698