How to set output verbosity level in ROOT?

Dear rooters,

There are several functions in TObject specifying different levels of output:

Info()
Warning()
Error()
SysError()
Fatal()

Is it possible to set the verbosity level so that ROOT will print messages with higher verbosity? For example, is there something like:

and then Info(), Warning() will be ignored, while Error(), SysError() and Fatal() will be called.

I guess ROOT has this kind of system. Is there any documentation or examples?

Cheers, Jing

Hi Jing,

you can set the verbosity via a global variable using an rootrc env variable, see $ROOTSYS/etc/system.rootrc:

# Ignore errors lower than the ignore level. Possible values:
# Print, Info, Warning, Error, Break, SysError and Fatal.
Root.ErrorIgnoreLevel:   Print

Or directly in the code via:

gErrorIgnoreLevel = kPrint, kInfo, kWarning, kError, kBreak, kSysError, kFatal;

setting it to kPrint will print all messages again.

We’ll add it to the manual (unfortunate omission).

Cheers, Fons.

Dear Fons,

thank you for pointing out another two levels that I didn’t noticed: kPrint and kBreak. However, how can I use them? The Print() function defined in TObject is quit different from Info(), Fatal(), etc. and I cannot find anything like Break().

Cheers, Jing

Dear Fons,

when shall I use Error() and when shall I use SysError()?

and will the execution of Fatal() terminate the program?

Cheers, Jing

Hi Jing,

use SysError() for any errors coming from system calls, like fopen(), read(), etc. Use Error() for your own errors and yes, Fatal() will abort the program.

Cheers, Fons.

Dear Fons,

thanks again.

some other questions:

You point out another two levels that I didn’t noticed: kPrint and kBreak. However, how can I use them? The Print() function defined in TObject is quit different from Info(), Fatal(), etc. and I cannot find anything like Break().

Cheers, Jing

See $ROOTSYS/inc/TError.h. There is a Break() function which is not accessible from the interpreter which is only used via the ROOT errorhandler. There is no Print() function but a Printf() function which uses the kPrint flag. Using Printf() as opposed to printf() allows you to also silence or easily redirect all “normal” messages.

Cheers, Fons.

Dear Fons,

Printf() does not accept location as the others do. I have the following levels in mind:

debug - debug info. Normal users don’t want to see them
routine - messages showing the progress of the program or tell users to do something
warning - program can still run, but users have to check something
error - program can still run, but users cannot get what they want anymore
fatal - program can not run anymore

and it would be good if the functions can pick up locations automatically so that the programmer can concentrate on the messages.

In ROOT, Info() is similar to routine, Warning() is like warning, Error() is like error, Fatal() is like fatal in my mind. But there is nothing like debug.

My question is how can I realize a system as the one in my mind based on the existing error handling functions in ROOT?

Cheers, Jing

Hi Jing,

in ROOT we use Info() for debug like:

if (gDebug > xxx)
Info(“location”, “x is %d and y is %d”, x, y);

The other messages are used as such.

Cheers, Fons.

Dear Fons,

clear, thanks!

Cheers, Jing

Hi,

Is it possible to choose more than one option out of all verbosity? Say, I want to choose kError and kWarning but not others. If possible, how to write inside the code?

I have tried
gErrorIgnoreLevel = kError, kWarning;

if I choose only kPrint, I see this error message :
Error: Symbol kPrint is not defined in current scope

Cheers,
Sumanta

@sumanta, did you use #include "TError.h"?

Yes, I have used #include “TError.h”.