Skip to content

Commit eac6ce0

Browse files
authored
Fix log output logic to not overwrite the last line of a multi-line log (#305)
1 parent 91838b2 commit eac6ce0

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

build_runner/lib/src/generate/options.dart

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44
import 'dart:async';
5+
import 'dart:convert';
56
import 'dart:io';
67

78
import 'package:build/build.dart';
@@ -105,12 +106,16 @@ void _defaultLogListener(LogRecord record) {
105106
}
106107
}
107108

108-
if (record.level > Level.INFO || !_isPosixTerminal) {
109+
var message = lines.join('\n');
110+
111+
var multiLine = LineSplitter.split(message).length > 1;
112+
113+
if (record.level > Level.INFO || !_isPosixTerminal || multiLine) {
114+
// Add an extra line to the output so the last line is written over.
109115
lines.add('');
116+
message = lines.join('\n');
110117
}
111118

112-
var message = lines.join('\n');
113-
114119
if (record.level >= Level.SEVERE) {
115120
stderr.write(message);
116121
} else {

build_runner/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: build_runner
2-
version: 0.3.4
2+
version: 0.3.5-dev
33
description: Tools to write binaries that run builders.
44
author: Dart Team <[email protected]>
55
homepage: https://github.com/dart-lang/build

0 commit comments

Comments
 (0)