Progress output as json

Forgive me if I've overlooked some way to do this, but I don't think it's currently possible to have progress output to stdout in json format. Note that I'm not talking about the --use-json-log option which affects the log file.

The use case is important if we are spawning rclone as a node.js child process, as this breaks the ability to output a pretty formatted progress to stdout without reading and processing the data as it gets streamed from the child process. If the output was json we could use childprocess.stdout.on('data') to read the progress stats and use other node.js methods to inform the user of progress in a polished output.

There could be a separate option called something like --use-json-progress that would accomplish this, while also keeping the formatting of the progress output separate from log file options. In my case, I'd want the progress output to be json but the log file output to be normal text.

Have a look at rc interface and especially at core-stats which returns stats about current transfer

--use-json-log with --stats 0.5s will give you pretty much what progress does in JSON format. You might want --stats-log-level NOTICE also.

You'll have to separate the log from the progress but that is easy.

Or use the rc as suggested above.

@ncw Do you mean to just not use the built-in file logger and instead use stats (which I believe writes to stderr)? I suppose that would work as I can then parse the stderr stream for the stats object and output everything else to a file.

The rc suggestion is good as well, though I think just parsing stderr will be a bit simpler for my particular use case.

Yes don't use --progress or -P I should have said that. --stats logs to the log file which is to stderr by default.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.