Is it possible to disable progress bar?


Hi all,

I have a simple function that should merge ROOT files:

bool merge_root_files(const std::string& outputFile, const std::vector<std::string>& inputFiles) //NOLINT(misc-use-internal-linkage)
{
    // Disable ROOT info messages (including the progress bar)
    gEnv->SetValue("TFile.PrintProgress", 0);   // disable progress bar
    const int oldLevel = gErrorIgnoreLevel;
    gErrorIgnoreLevel = kWarning;   // ignore Info messages

    TFileMerger merger;
    merger.SetPrintLevel(0);
    merger.OutputFile(outputFile.c_str());

    for (const auto& ifile : inputFiles) {
        if (!merger.AddFile(ifile.c_str())) {
            throw std::runtime_error( "MergeRootFiles: could not add file " + ifile );
        }
    }

    const bool resultok = merger.Merge();
    // Restore previous level
    gErrorIgnoreLevel = oldLevel;
    if (!resultok) {
        throw std::runtime_error("MergeRootFiles: Error: merging failed for output "+ outputFile );
    }
    return resultok;
}



But during the execution, I see a lot of progress bars like this:

 [TFile::Cp] Total 0.22 MB	|====================| 100.00 % [549.2 MB/s]

Is there a way to disable them?

Best regards,

Andrii

ROOT Version: 6.38.00
Platform: EL9
Compiler: gcc 10.5


Hello @av1,

you should be able to silence the progressbars by passing false as the second argument to merger.AddFile:

   if (!merger.AddFile(ifile.c_str(), false)) { // <- here
       // ...
1 Like

Wow, thank you for the quick reply, @silverweed! It has worked like a charm.

Many thanks!

Andrii