Skip to content

Commit 0b03330

Browse files
committed
Change a number of stdout outputs to stderr to not break piped output
See #7116 Signed-off-by: Phil Ewels <phil.ewels@seqera.io>
1 parent f540396 commit 0b03330

5 files changed

Lines changed: 21 additions & 21 deletions

File tree

modules/nextflow/src/main/groovy/nextflow/cli/CmdRun.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ class CmdRun extends CmdBase implements HubOptions {
469469
// Show Nextflow version
470470
fmt.a(Attribute.INTENSITY_FAINT).a(" ~ ").reset().a("version " + BuildInfo.version).reset()
471471
fmt.a("\n")
472-
AnsiConsole.out.println(fmt.eraseLine())
472+
AnsiConsole.err.println(fmt.eraseLine())
473473
}
474474
else {
475475
// Plain header to the console if ANSI is disabled
@@ -527,7 +527,7 @@ class CmdRun extends CmdBase implements HubOptions {
527527
fmt.fg(Color.CYAN).a("revision: ").reset()
528528
fmt.fg(Color.CYAN).a(revision).reset()
529529
fmt.a("\n")
530-
AnsiConsole.out().println(fmt.eraseLine())
530+
AnsiConsole.err().println(fmt.eraseLine())
531531
}
532532
else {
533533
log.info "${head} [$runName] - revision: ${revision}"

modules/nextflow/src/main/groovy/nextflow/trace/AgentLogObserver.groovy

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ class AgentLogObserver implements TraceObserverV2, LogObserver {
5959
}
6060

6161
/**
62-
* Print a line to standard output (agent format)
62+
* Print a line to standard error (agent format)
6363
*/
6464
protected void printLine(String line) {
65-
System.out.println(line)
65+
System.err.println(line)
6666
}
6767

6868
// -- TraceObserverV2 lifecycle methods --
@@ -152,13 +152,13 @@ class AgentLogObserver implements TraceObserverV2, LogObserver {
152152
}
153153

154154
/**
155-
* Append info message to stdout.
155+
* Append info message to stderr.
156156
* Hash-prefixed task log lines (e.g. {@code [ab/123456] Submitted process > ...})
157157
* are filtered out because {@link #onTaskSubmit} already emits a {@code [PROCESS]} line.
158158
*/
159159
void appendInfo(String message) {
160160
if( message && !LoggerHelper.isHashLogPrefix(message) )
161-
System.out.print(message)
161+
System.err.print(message)
162162
}
163163

164164
/**

modules/nextflow/src/main/groovy/nextflow/trace/AnsiLogObserver.groovy

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ class AnsiLogObserver implements TraceObserverV2, LogObserver {
317317

318318
synchronized protected void renderProgress(WorkflowStats stats) {
319319
if( printedLines )
320-
AnsiConsole.out.println ansi().cursorUp(printedLines+gapLines+1)
320+
AnsiConsole.err.println ansi().cursorUp(printedLines+gapLines+1)
321321

322322
// -- print processes
323323
final term = ansi()
@@ -330,14 +330,14 @@ class AnsiLogObserver implements TraceObserverV2, LogObserver {
330330

331331
final str = term.toString()
332332
final count = printAndCountLines(str)
333-
AnsiConsole.out.flush()
333+
AnsiConsole.err.flush()
334334

335335
// usually the gap should be negative because `count` should be greater or equal
336336
// than the previous `printedLines` value (the output should become longer)
337337
// otherwise cleanup the remaining lines
338338
gapLines = printedLines > count ? printedLines-count : 0
339339
if( gapLines>0 ) for(int i=0; i<gapLines; i++ )
340-
AnsiConsole.out.print(ansi().eraseLine().newline())
340+
AnsiConsole.err.print(ansi().eraseLine().newline())
341341
// at the end update the value of printed lines
342342
printedLines = count
343343
}
@@ -396,7 +396,7 @@ class AnsiLogObserver implements TraceObserverV2, LogObserver {
396396
report += "Failed : ${stats.failedCountFmt}\n"
397397

398398
printAnsi(report, Color.GREEN, true)
399-
AnsiConsole.out.flush()
399+
AnsiConsole.err.flush()
400400
}
401401
}
402402

@@ -407,14 +407,14 @@ class AnsiLogObserver implements TraceObserverV2, LogObserver {
407407
fmt = fmt.a(message)
408408
if( bold ) fmt = fmt.boldOff()
409409
if( color ) fmt = fmt.fg(Color.DEFAULT)
410-
AnsiConsole.out.println(fmt.eraseLine())
410+
AnsiConsole.err.println(fmt.eraseLine())
411411
}
412412

413413
protected void printAnsiLines(String lines) {
414414
final text = lines
415415
.replace('\r','')
416416
.replace(NEWLINE, ansi().eraseLine().toString() + NEWLINE)
417-
AnsiConsole.out.print(text)
417+
AnsiConsole.err.print(text)
418418
}
419419

420420
protected String fmtWidth(String name, int width, int cols) {

modules/nextflow/src/main/groovy/nextflow/util/LoggerHelper.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ class LoggerHelper {
718718
final observer = session?.logObserver
719719
if( observer ) {
720720
if( !observer.started || observer.stopped )
721-
System.out.println(message)
721+
System.err.println(message)
722722
else if( event.marker == STICKY )
723723
observer.appendSticky(message)
724724
else if( event.level==Level.ERROR )
@@ -729,7 +729,7 @@ class LoggerHelper {
729729
observer.appendInfo(message)
730730
}
731731
else {
732-
System.out.println(message)
732+
System.err.println(message)
733733
}
734734
}
735735
catch (Throwable e) {

modules/nextflow/src/main/groovy/nextflow/util/SpinnerUtil.groovy

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ class SpinnerUtil {
9595
fmt.a("\r").eraseLine(Erase.ALL)
9696
fmt.fg(parseColor(colorName)).a(spinnerChars[spinnerIndex]).reset()
9797
fmt.a(" ").a(message)
98-
AnsiConsole.out.print(fmt.toString())
99-
AnsiConsole.out.flush()
98+
AnsiConsole.err.print(fmt.toString())
99+
AnsiConsole.err.flush()
100100
spinnerIndex = (spinnerIndex + 1) % spinnerChars.length
101101
Thread.sleep(SPINNER_UPDATE_MS)
102102
}
@@ -211,8 +211,8 @@ class SpinnerUtil {
211211
if (ansiEnabled && clearLine) {
212212
def fmt = Ansi.ansi()
213213
fmt.a("\r").eraseLine(Erase.ALL)
214-
AnsiConsole.out.print(fmt.toString())
215-
AnsiConsole.out.flush()
214+
AnsiConsole.err.print(fmt.toString())
215+
AnsiConsole.err.flush()
216216
}
217217

218218
spinnerThread = null
@@ -238,10 +238,10 @@ class SpinnerUtil {
238238
def fmt = Ansi.ansi()
239239
fmt.a("\r").eraseLine(Erase.ALL)
240240
fmt.a(finalMessage).a("\n")
241-
AnsiConsole.out.print(fmt.toString())
242-
AnsiConsole.out.flush()
241+
AnsiConsole.err.print(fmt.toString())
242+
AnsiConsole.err.flush()
243243
} else {
244-
println finalMessage
244+
System.err.println(finalMessage)
245245
}
246246

247247
spinnerThread = null

0 commit comments

Comments
 (0)