Log messages with typed Properties

  • We use the operator << that is overloaded, it can have a typed Property as parameter.
  • Log the formatted property and its unit directly.


log(Level::s_Info) << " finished at " << position << " (" << position.setpoint << ")" << endlog;

Declaration and instantiation of the typed Property of the example:

Property<float64, SETPOINT> position;
Property<string> unit;

position.init(this, SAVE | SCAN, "actual_position", "wanted_position", "Position");
unit.init(this, SAVE, "unit", "Unit");

Automatic log of Properties

Only non setpoint Properties can be loggable. The flags LOG_INFO and LOG_DEBUG can be used:

Property<float64> setting;

setting.init(this, SAVE | LOG_INFO, "setting", "Setting");

Log messages with hidden typed Properties

If we want to log properties without their string output, we can use the property function. For example:

                  .property(config) << " finished at " << position << " (" << position.setpoint << ")" << endlog;

The properties title and config are hidden properties.

Log messages with "classic" properties

  • We use the same procedure than before, that is, use of the operator <<
  • Replace stringstream by an instance of LogStream.
  • For any property that must be logged:
    • We will use the method plog of the class AbstractController. The signature of the method is:
      PLog AbstractController::plog(std::string const & propertyName)
    • The value and unit of the property will be logged by using the methods of the PLog class:
      value(std::string const & propertyValue)
      unit(std::string const & propertyUnit)
  • The log messages end always with endlog.

Example: Log message in Count controller

stringstream logMessage;
logMessage << "Numor: " << boost::format("%06d") % m_ExperimentData->getNumor();
log((logging ? Level::s_Info : Level::s_Debug)) << emptycursor << logMessage.str() << endlog;


LogStream logStream =  log((logging ? Level::s_Info : Level::s_Debug));
stringstream numorValue;
numorValue << m_ExperimentData->getNumor();
logStream << emptycursor << "Numor: "<< plog(NUMOR_PROPERTY).value(numorValue.str()).unit("") << endlog;