-
Notifications
You must be signed in to change notification settings - Fork 87
migrate the build command to use the build daemon #298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| import 'dart:io'; | ||
|
|
||
| import 'package:io/ansi.dart'; | ||
| import 'package:build_daemon/data/server_log.dart'; | ||
| import 'package:logging/logging.dart'; | ||
|
|
||
| var _verbose = false; | ||
|
|
@@ -46,3 +47,24 @@ void _colorLog(Level level, String message, {bool verbose}) { | |
| stdout.writeln(''); | ||
| } | ||
| } | ||
|
|
||
| /// Trims [level] from [message] if it is prefixed by it. | ||
| String trimLevel(Level level, String message) => message.startsWith('[$level]') | ||
| ? message.replaceFirst('[$level]', '').trimLeft() | ||
| : message; | ||
|
|
||
| /// Detects if the [ServerLog] contains a [Level] and returns the | ||
| /// resulting value. | ||
| /// | ||
| /// If the [ServerLog] does not contain a [Level], null will be returned. | ||
| Level levelForLog(ServerLog serverLog) { | ||
| var log = serverLog.log; | ||
| Level recordLevel; | ||
| for (var level in Level.LEVELS) { | ||
| if (log.startsWith('[$level]')) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're going to end up building this string over and over. I wonder if we want something like: final levelsByLabel = Map.fromIterable(Level.LEVELS, key: (l) => '[$l]'); // should be static
...
var messageLabel = levelsByLabel.keys.firstWhere(log.startsWith);
return messageLabel == null ? null : levelsByLabel[messageLabel];Then we can look forward to writing it instead as var levelsByLabel = {for (var l in Level.LEVELS) '[$l]': l};
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just moved these utilities around in this pr since they aren't specific to the serve command any more, we could follow up with something but I think we have a lot of other much slower things going on in the logging than this :D. Also probably a switch statement or something would probably be faster than a map for that if we are concerned about perf? |
||
| recordLevel = level; | ||
| break; | ||
| } | ||
| } | ||
| return recordLevel; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.