QDlt Example
This Example shows how to use DLT.
This Example shows how to use DLT.
First we need to register our example application with the dlt-daemon.
QDLT_REGISTER_APPLICATION("APP1", "Description for APP")
Our application is now registered under the id APP1
. All logging categories registered are associated with this id. The description is only used within the dlt-viewer application and is useful to further describe the application as the four byte long id is not very descriptive.
The next step is to register our logging categories and a fallback category. The fallback category is used for all logs, which are either uncategorized e.g. by using qDebug instead of qCDebug or are using a Qt message category which is not registered as a DLT category.
QDLT_LOGGING_CATEGORY(FOO, "com.pelagicore.foo", "FOO", "FOO CATEGORY") QDLT_LOGGING_CATEGORY(BAR, "com.pelagicore.bar", "BAR", "BAR CATEGORY") QDLT_FALLBACK_CATEGORY(FOO)
Similar to the Q_LOGGING_CATEGORY macro, the first two arguments define the category's name and the identifier used to control the category. In addition, every DLT logging category needs to have a four byte long id and a description. These last two fields are used to identify the logs in the dlt-viewer.
The final step to enable DLT logging is to register the special dlt messageHandler.
qInstallMessageHandler(QDltRegistration::messageHandler);
This handler will pick-up the logs and send it to the dlt-daemon.
{The example application and its logging categories in the dlt-viewer}
Files:
© 2020 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.