Support --quiet
This commit is contained in:
parent
e2d03b7389
commit
d5ac42c0cc
1 changed files with 16 additions and 10 deletions
|
@ -35,7 +35,8 @@ _ ___ | /| / / /_/ / _ /___ _ /___
|
||||||
|
|
||||||
''';
|
''';
|
||||||
|
|
||||||
static void handleLogRecord(LogRecord record) {
|
static void handleLogRecord(LogRecord record, RunnerOptions options) {
|
||||||
|
if (options.quiet) return;
|
||||||
var code = chooseLogColor(record.level);
|
var code = chooseLogColor(record.level);
|
||||||
|
|
||||||
if (record.error == null) print(code.wrap(record.toString()));
|
if (record.error == null) print(code.wrap(record.toString()));
|
||||||
|
@ -93,25 +94,30 @@ _ ___ | /| / / /_/ / _ /___ _ /___
|
||||||
.then((isolate) {})
|
.then((isolate) {})
|
||||||
.catchError(c.completeError);
|
.catchError(c.completeError);
|
||||||
|
|
||||||
onLogRecord.listen((msg) => handleLogRecord(msg as LogRecord));
|
onLogRecord.listen((msg) => handleLogRecord(msg as LogRecord, options));
|
||||||
|
|
||||||
onError.listen((msg) {
|
onError.listen((msg) {
|
||||||
if (msg is List) {
|
if (msg is List) {
|
||||||
var e = msg[0], st = StackTrace.fromString(msg[1].toString());
|
var e = msg[0], st = StackTrace.fromString(msg[1].toString());
|
||||||
handleLogRecord(LogRecord(
|
handleLogRecord(
|
||||||
Level.SEVERE, 'Fatal error', runnerArgs.loggerName, e, st));
|
LogRecord(
|
||||||
|
Level.SEVERE, 'Fatal error', runnerArgs.loggerName, e, st),
|
||||||
|
options);
|
||||||
} else {
|
} else {
|
||||||
handleLogRecord(
|
handleLogRecord(
|
||||||
LogRecord(Level.SEVERE, 'Fatal error', runnerArgs.loggerName, msg));
|
LogRecord(Level.SEVERE, 'Fatal error', runnerArgs.loggerName, msg),
|
||||||
|
options);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onExit.listen((_) {
|
onExit.listen((_) {
|
||||||
if (options.respawn) {
|
if (options.respawn) {
|
||||||
handleLogRecord(LogRecord(
|
handleLogRecord(
|
||||||
Level.WARNING,
|
LogRecord(
|
||||||
'Instance #$id at ${DateTime.now()} crashed. Respawning immediately...',
|
Level.WARNING,
|
||||||
runnerArgs.loggerName));
|
'Instance #$id at ${DateTime.now()} crashed. Respawning immediately...',
|
||||||
|
runnerArgs.loggerName),
|
||||||
|
options);
|
||||||
_spawnIsolate(id, c, options, pubSubSendPort);
|
_spawnIsolate(id, c, options, pubSubSendPort);
|
||||||
} else {
|
} else {
|
||||||
c.complete();
|
c.complete();
|
||||||
|
@ -206,7 +212,7 @@ _ ___ | /| / / /_/ / _ /___ _ /___
|
||||||
|
|
||||||
if (app.logger == null) {
|
if (app.logger == null) {
|
||||||
app.logger = Logger(args.loggerName)
|
app.logger = Logger(args.loggerName)
|
||||||
..onRecord.listen(Runner.handleLogRecord);
|
..onRecord.listen((rec) => Runner.handleLogRecord(rec, args.options));
|
||||||
}
|
}
|
||||||
|
|
||||||
AngelHttp http;
|
AngelHttp http;
|
||||||
|
|
Loading…
Reference in a new issue