Skip to content

Latest commit

 

History

History
72 lines (52 loc) · 2.6 KB

consumer.rst

File metadata and controls

72 lines (52 loc) · 2.6 KB

Consumers

Consumers are classes that take a |Log::Entry-api| and produce a log output accordingly. eProsima Fast DDS provides three different log consumers that output log entries to different streams:

StdoutConsumer

|StdoutConsumer-api| outputs log entries to STDOUT stream following the convection specified in :ref:`dds_layer_log_logging_spec`. It is the default and only log consumer of the logging module if the CMake option |LOG_CONSUMER_DEFAULT| is set to AUTO, STDOUT, or not set at all. It can be registered and unregistered using the methods explained in :ref:`dds_layer_log_register_consumers` and :ref:`dds_layer_log_reset`.

.. literalinclude:: /../code/DDSCodeTester.cpp
    :language: c++
    :start-after: //LOG_STDOUT_CONSUMER
    :end-before: //!--
    :dedent: 4


StdoutErrConsumer

|StdoutErrConsumer-api| uses a |Log::Kind-api| threshold to filter the output of the log entries. Those log entries whose |Log::Kind-api| is equal to or more severe than the given threshold output to STDERR. Other log entries output to STDOUT. By default, the threshold is set to |Log::Kind::Warning-api|. |StdoutErrConsumer::stderr_threshold-api| allows the user to modify the default threshold.

Additionally, if CMake option |LOG_CONSUMER_DEFAULT| is set to STDOUTERR, the logging module will use this consumer as the default log consumer.

.. literalinclude:: /../code/DDSCodeTester.cpp
    :language: c++
    :start-after: //LOG_STDOUTERR_CONSUMER
    :end-before: //!--
    :dedent: 4


FileConsumer

|FileConsumer-api| provides the logging module with log-to-file logging capabilities. Applications willing to hold a persistent execution log record can specify a logging file using this consumer. Furthermore, the application can choose whether the file stream should be in "write" or "append" mode, according to the behaviour defined by |std::fstream::open-api|.

.. literalinclude:: /../code/DDSCodeTester.cpp
    :language: c++
    :start-after: //LOG_FILE_CONSUMER
    :end-before: //!--
    :dedent: 4