DDS Python API: Logging into console

4 posts / 0 new
Last post
Offline
Last seen: 1 year 5 months ago
Joined: 11/23/2021
Posts: 32
DDS Python API: Logging into console

Hello @All,

is there a possibility to log dds domain traffic directly into console instead of a file using the Python API?

When using XML along with the Python API, this should be possible according the description inside the following link:

https://community.rti.com/kb/enabling-logging-xml-qos-file

"Logging Option 1:    No log file specified. If no log file is specified, the results are printed to the console (typically stdout)."

 

Is this somehow possible using methods of the python API?

If I dont provide a name to the output file using funtion output_file(), I will get an error!

logger = dds.Logger
logger.output_file(logger.instance, None)
 
Thanks in Advance!
 
Regards,
Marc
Howard's picture
Offline
Last seen: 5 hours 57 min ago
Joined: 11/29/2012
Posts: 610

Hi Marc,

By default, the Connext logger is already sending logs to stdout.

The community link that you're referring to is not about Python as much as it is about configuring logging via a QoS Profile defined in XML.

You can easily turn logging to output at a higher verbosity (by default, it only logs at the ERROR level), by including this in the USER_QOS_PROFILES file:

      <qos_profile name="Factory_Profile" is_default_participant_factory_profile="true">
        <!-- QoS used to configure the data writer created in the example code -->
        <participant_factory_qos>
          <entity_factory>
            <autoenable_created_entities>false</autoenable_created_entities>
          </entity_factory>
            <logging>
              <category>ALL</category>
              <verbosity>ALL</verbosity>
            </logging>
          </participant_factory_qos>
      </qos_profile>

If you want to change the verbosity higher via the Connext API in python, you have to do this equivalently:

    logger = dds.Logger.instance;       
    logger.verbosity_by_category(dds.LogCategory.ALL_CATEGORIES, dds.Verbosity.STATUS_ALL);

Using ALL categorites and STATUS_ALL will produce lots and lots of fairly useless output.  I would suggest that dds.Verbosity.WARNING is relatively useful, not sure exactly what you want to do.

By doing either of the above, you'll see Connext DDS log messages in the same shell that you start your python application (or at least in whatever window that stdout goes to).

 

Offline
Last seen: 1 year 5 months ago
Joined: 11/23/2021
Posts: 32

Hello Howard,

Thanks for the feedback. I solved the issue by the following:

If I don‘t specify a file to store the logging content via one of

the methods (Logger.instance.output_file() or Logger.instance.output_file_set()), it prints everything directly into the console.

Regards,

Marc

Howard's picture
Offline
Last seen: 5 hours 57 min ago
Joined: 11/29/2012
Posts: 610

Thanks for your update!