flutterdartprocessstdoutcommon-workflow-language

Flutter/Dart - Print output of all child processes to stdout


I am developing a Flutter desktop app, which at some point runs a Process. For this process I want to read the output and do things in Flutter according to it. The problem I am having is that not all output gets is shown via process.stdout, namely some INFO logs I would want to read as well.

Here's the (very simple) code:

Process process = await Process.start(
    "cwltool",
    [
        "--verbose",
        "Oesophageal-varices.cwl",
        "Oesophageal-varices-inputs.yml"
    ],
);

await process.stdout
    .transform(utf8.decoder)
    .forEach(print)

With this, the output is only:

{
    "cases": {
        "location": "file:///somelocation/oesophageal-varices-cases.csv",
        "basename": "oesophageal-varices-cases.csv",
        "class": "File",
        "checksum": "sha1$0b3f04bbeaac24499166fd56d93ad8bd6acb9ca8",
        "size": 670,
        "path": "/somelocation/oesophageal-varices-cases.csv"
    }
}

But when I run the same process in terminal, it also prints INFO logs, which I would desperately need in Flutter. I suspect the logging done by a python child process underneath is not passed on to process.stdout, hence them not printing.

How would I go about accessing the INFO logs too using Dart?


Solution

  • As pskink commented, interestingly enough the logs are going to process.stderr.