Rivet is hosted by Hepforge, IPPP Durham


Logging in Rivet is done via the Log class, which defines several log "levels": DEBUG, INFO, WARN and ERROR. For example, DEBUG messages don't get written out unless the logger is configured at runtime to level DEBUG or below. Loggers are named and hierarchical, so that fine control of the output levels is possible.

Command line control

On the command line, the -l switch is used to control log levels, e.g.

rivetgun ... -l Rivet.Analysis=DEBUG

will make all analyses output messages at the DEBUG level and above. Finer-grained control is possible, e.g.

rivetgun ... -l Rivet.Analysis=WARN -l Rivet.Analysis.Foo=DEBUG

The same logging control is present on both the rivet and rivetgun executables.

Coding with Log objects

In projection and analysis classes, the Projection and Analysis base classes define and implement a getLog() method, which will retrieve a logger object named according to the getName() of the user class. The hierarchy is automatically used by this method, so that an analysis named "Foo" will automatically be in logger class "Rivet.Analysis.Foo". A similarly-named projection will be in class "Rivet.Projection.Foo".

To actually use the Log class in your code (which you must: cout and cerr are banned!), you get hold of a reference to one like so:

Log& log = getLog(); // in Analysis or Projection
// or Log& log = Log::getLog("Foo.Bar.Baz");

and use it like a special cout stream. The "special" is that the first argument must be one of the log level enums, which are defined as static in the Log class:

log << Log::DEBUG << "This is a debug message" << endl;

That's all! Note that we use references to the Log object so that only one is ever created: this keeps the memory occupancy of the logging system low.

Last modified 8 years ago Last modified on Dec 14, 2009, 10:57:50 AM