Nextflow: log messages don't show in console output when ansi logging is enabled

Created on 25 Apr 2019  路  10Comments  路  Source: nextflow-io/nextflow

Bug report

Expected behavior and actual behavior

Expected behaviour: log.info "foo" should print to STDOUT.
Actual behaviour: log.info "foo" only prints to .nextflow.log _unless_ NXF_ANSI_LOG=false

Steps to reproduce the problem

NXF_ANSI_LOG=false nextflow run nf-core/hlatyping -r dev -profile test -> prints nfcoreHeader() to console
nextflow run nf-core/hlatyping -r dev -profile test -> doesn't print nfcoreHeader() to console

Environment

  • Nextflow version: [19.04.0]
  • Java version: [1.8.0_202]
  • Operating system: [Linux]
kinbug

Most helpful comment

Squashed. The nf-core banner now is printed tho there's a small glitch, but I think it's related to the ansi codes you are using

[2m----------------------------------------------------
                                        ,--./,-.
        ___     __   __   __   ___     /,-._.--~'
  |\ | |__  __ /  ` /  \ |__) |__         }  {
  | \| |       \__, \__/ |  \ |___     \`-._,-`-,
                                        `._,._,'
----------------------------------------------------

All 10 comments

Not able to replicate this. Do you mean a script with just the line log.info "foo" does not print it ?

That example was maybe too minimal, sorry. It seems to me that with the ansi logging, not all log.info statements get printed to console. They do get printed to .nextflow.log however.

For example the following script:

#!/usr/bin/env nextflow

params.monochrome_logs = false

def helpMessage() {
    log.info nfcoreHeader()
    log.info "foo"
}

def nfcoreHeader(){
    // Log colors ANSI codes
    c_reset = params.monochrome_logs ? '' : "\033[0m";
    c_dim = params.monochrome_logs ? '' : "\033[2m";
    c_black = params.monochrome_logs ? '' : "\033[0;30m";
    c_green = params.monochrome_logs ? '' : "\033[0;32m";
    c_yellow = params.monochrome_logs ? '' : "\033[0;33m";
    c_blue = params.monochrome_logs ? '' : "\033[0;34m";
    c_purple = params.monochrome_logs ? '' : "\033[0;35m";
    c_cyan = params.monochrome_logs ? '' : "\033[0;36m";
    c_white = params.monochrome_logs ? '' : "\033[0;37m";

    return """    ${c_dim}----------------------------------------------------${c_reset}
                                            ${c_green},--.${c_black}/${c_green},-.${c_reset}
    ${c_blue}        ___     __   __   __   ___     ${c_green}/,-._.--~\'${c_reset}
    ${c_blue}  |\\ | |__  __ /  ` /  \\ |__) |__         ${c_yellow}}  {${c_reset}
    ${c_blue}  | \\| |       \\__, \\__/ |  \\ |___     ${c_green}\\`-._,-`-,${c_reset}
                                            ${c_green}`._,._,\'${c_reset}
    ${c_dim}----------------------------------------------------${c_reset}
    """.stripIndent()
}

helpMessage()

workflow.onComplete {
    if ( workflow.success ) {
      log.info "[$workflow.complete] >> Script finished SUCCESSFULLY after $workflow.duration"
    } else {
      log.info "[$workflow.complete] >> Script finished with ERRORS after $workflow.duration"
    }
}

If run with nextflow run script.nf it only prints foo to console, whereas when I run it with
NXF_ANSI_LOG=false nextflow run script.nf it prints both nfcoreHeader() and footo console.

Ohh, nf-core in technicolor .. 馃槀(let me try)

Wait, the exit 0 is suspicious and surely it should only be used to report errors, not to termite successful executions. Can you try to remove it?

Agreed, don't know why I put it there. Doesn't change the behaviour though.

Edit:
I'd like to point out that it is also not specific to the fancy coloured header, but also affects e.g. completion handlers. I added a basic example in the code above.

@pditommaso Im seeing the same behaviour with another pipeline too. When -ansi is switched off the header is printed.

Ouch, now I'm able to replicate it.

Squashed. The nf-core banner now is printed tho there's a small glitch, but I think it's related to the ansi codes you are using

[2m----------------------------------------------------
                                        ,--./,-.
        ___     __   __   __   ___     /,-._.--~'
  |\ | |__  __ /  ` /  \ |__) |__         }  {
  | \| |       \__, \__/ |  \ |___     \`-._,-`-,
                                        `._,._,'
----------------------------------------------------

Great!

Included in version 19.04.1.

Was this page helpful?
0 / 5 - 0 ratings