Skip to content
This repository has been archived by the owner on Feb 17, 2020. It is now read-only.

Commit

Permalink
Support --quiet
Browse files Browse the repository at this point in the history
  • Loading branch information
thosakwe committed Apr 28, 2019
1 parent e2d03b7 commit d5ac42c
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions lib/src/runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);

if (record.error == null) print(code.wrap(record.toString()));
Expand Down Expand Up @@ -93,25 +94,30 @@ _ ___ | /| / / /_/ / _ /___ _ /___
.then((isolate) {})
.catchError(c.completeError);

onLogRecord.listen((msg) => handleLogRecord(msg as LogRecord));
onLogRecord.listen((msg) => handleLogRecord(msg as LogRecord, options));

onError.listen((msg) {
if (msg is List) {
var e = msg[0], st = StackTrace.fromString(msg[1].toString());
handleLogRecord(LogRecord(
Level.SEVERE, 'Fatal error', runnerArgs.loggerName, e, st));
handleLogRecord(
LogRecord(
Level.SEVERE, 'Fatal error', runnerArgs.loggerName, e, st),
options);
} else {
handleLogRecord(
LogRecord(Level.SEVERE, 'Fatal error', runnerArgs.loggerName, msg));
LogRecord(Level.SEVERE, 'Fatal error', runnerArgs.loggerName, msg),
options);
}
});

onExit.listen((_) {
if (options.respawn) {
handleLogRecord(LogRecord(
Level.WARNING,
'Instance #$id at ${DateTime.now()} crashed. Respawning immediately...',
runnerArgs.loggerName));
handleLogRecord(
LogRecord(
Level.WARNING,
'Instance #$id at ${DateTime.now()} crashed. Respawning immediately...',
runnerArgs.loggerName),
options);
_spawnIsolate(id, c, options, pubSubSendPort);
} else {
c.complete();
Expand Down Expand Up @@ -206,7 +212,7 @@ _ ___ | /| / / /_/ / _ /___ _ /___

if (app.logger == null) {
app.logger = Logger(args.loggerName)
..onRecord.listen(Runner.handleLogRecord);
..onRecord.listen((rec) => Runner.handleLogRecord(rec, args.options));
}

AngelHttp http;
Expand Down

0 comments on commit d5ac42c

Please sign in to comment.