From f33fae3050a8edaec46446aab38cc1b3dd45adfc Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Wed, 17 Apr 2019 15:48:11 -0700 Subject: [PATCH 1/2] Drop hardcoded list of known logger names Now that there is a split with some of these logger names coming from `build_runner_core` it's not as easy to roll out changes which introduce new logger names. The only cases where we do want to show the logger name are the ones where we are running actions and will always fit the pattern of `'$builderLabel on $input'`. --- .../lib/src/logging/std_io_logging.dart | 33 +++---------------- 1 file changed, 5 insertions(+), 28 deletions(-) diff --git a/build_runner/lib/src/logging/std_io_logging.dart b/build_runner/lib/src/logging/std_io_logging.dart index 1d96e4ca96..f8697d4cda 100644 --- a/build_runner/lib/src/logging/std_io_logging.dart +++ b/build_runner/lib/src/logging/std_io_logging.dart @@ -26,7 +26,7 @@ StringBuffer colorLog(LogRecord record, {bool verbose}) { final level = color.wrap('[${record.level}]'); final eraseLine = ansiOutputEnabled && !verbose ? '\x1b[2K\r' : ''; var lines = [ - '$eraseLine$level ${_loggerName(record, verbose)}${record.message}' + '$eraseLine$level ${_recordHeader(record, verbose)}${record.message}' ]; if (record.error != null) { @@ -57,34 +57,11 @@ StringBuffer colorLog(LogRecord record, {bool verbose}) { void _stdIOLogListener(LogRecord record, {bool verbose}) => stdout.write(colorLog(record, verbose: verbose)); -/// Filter out the Logger names known to come from `build_runner` and splits the -/// header for levels >= WARNING. -String _loggerName(LogRecord record, bool verbose) { - var knownNames = const [ - 'ApplyBuilders', - 'Bootstrap', - 'Build', - 'BuildConfigOverrides', - 'BuildDefinition', - 'BuildOptions', - 'BuildScriptUpdates', - 'CreateOutputDir', - 'Entrypoint', - 'Heartbeat', - 'IOEnvironment', - 'Serve', - 'Watch', - 'build_runner', - // commands - 'build', - 'clean', - 'doctor', - 'serve', - 'test', - 'watch', - ]; +/// Filter out the Logger names which aren't coming from specific builders and +/// splits the header for levels >= WARNING. +String _recordHeader(LogRecord record, bool verbose) { var maybeSplit = record.level >= Level.WARNING ? '\n' : ''; - return verbose || !knownNames.contains(record.loggerName) + return verbose || record.loggerName.contains(' on ') ? '${record.loggerName}:$maybeSplit' : ''; } From 7b1f708ce981cbbd17b5fb1cc5dc4a1e0a772e68 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Mon, 22 Apr 2019 10:37:02 -0700 Subject: [PATCH 2/2] Look for any logger name with a space --- build_runner/lib/src/logging/std_io_logging.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_runner/lib/src/logging/std_io_logging.dart b/build_runner/lib/src/logging/std_io_logging.dart index f8697d4cda..96231b6886 100644 --- a/build_runner/lib/src/logging/std_io_logging.dart +++ b/build_runner/lib/src/logging/std_io_logging.dart @@ -61,7 +61,7 @@ void _stdIOLogListener(LogRecord record, {bool verbose}) => /// splits the header for levels >= WARNING. String _recordHeader(LogRecord record, bool verbose) { var maybeSplit = record.level >= Level.WARNING ? '\n' : ''; - return verbose || record.loggerName.contains(' on ') + return verbose || record.loggerName.contains(' ') ? '${record.loggerName}:$maybeSplit' : ''; }