LCOV - code coverage report
Current view: top level - zephyr/logging - log_backend_mqtt.h Coverage Total Hit
Test: new.info Lines: 100.0 % 3 3
Test Date: 2025-09-05 16:43:28

            Line data    Source code
       1            1 : /*
       2              :  * Copyright (c) 2024 Arif Balik <arifbalik@outlook.com>
       3              :  *
       4              :  * SPDX-License-Identifier: Apache-2.0
       5              :  */
       6              : 
       7              : /**
       8              :  * @file
       9              :  * @brief Header file for the MQTT log backend API
      10              :  * @ingroup log_backend_mqtt
      11              :  */
      12              : 
      13              : #ifndef ZEPHYR_INCLUDE_LOGGING_LOG_BACKEND_MQTT_H_
      14              : #define ZEPHYR_INCLUDE_LOGGING_LOG_BACKEND_MQTT_H_
      15              : 
      16              : #include <zephyr/net/mqtt.h>
      17              : 
      18              : #ifdef __cplusplus
      19              : extern "C" {
      20              : #endif
      21              : 
      22              : /**
      23              :  * @brief MQTT log backend API
      24              :  * @defgroup log_backend_mqtt MQTT log backend API
      25              :  * @ingroup log_backend
      26              :  * @{
      27              :  */
      28              : 
      29              : /**
      30              :  * @brief Set the MQTT client instance to be able to publish application's log messages to broker.
      31              :  *
      32              :  * This function allows the application to provide its own initialized
      33              :  * MQTT client to the log backend. The backend will use this client
      34              :  * exclusively for publishing log messages via mqtt_publish().
      35              :  *
      36              :  * @param client Pointer to an initialized and connected MQTT client.
      37              :  *               The client must remain valid for the lifetime of the
      38              :  *               log backend usage. Pass NULL to disable MQTT logging.
      39              :  *
      40              :  * @return 0 on success, negative error code on failure.
      41              :  *
      42              :  * @note The MQTT client must be connected before calling this function.
      43              :  * @note The backend will not manage the client connection - this is the
      44              :  *       responsibility of the application.
      45              :  * @note The backend will only use mqtt_publish() and will not perform
      46              :  *       any other operations on the client.
      47              :  */
      48            1 : int log_backend_mqtt_client_set(struct mqtt_client *client);
      49              : 
      50              : /**
      51              :  * @brief Set the MQTT topic to which log messages will be published.
      52              :  *
      53              :  * Allows the application to specify the MQTT topic that the log backend
      54              :  * will use for publishing log messages to.
      55              :  *
      56              :  * @param topic Pointer to a null-terminated string containing the MQTT topic.
      57              :  *              The topic must remain valid for the lifetime of the log backend usage.
      58              :  *
      59              :  * @return 0 on success, negative error code on failure.
      60              :  *
      61              :  * @note The topic must be a valid UTF-8 string, null-terminated and should not exceed
      62              :  *       the maximum length supported by the MQTT broker.
      63              :  */
      64            1 : int log_backend_mqtt_topic_set(const char *topic);
      65              : 
      66              : /**
      67              :  * @}
      68              :  */
      69              : 
      70              : #ifdef __cplusplus
      71              : }
      72              : #endif
      73              : 
      74              : #endif /* ZEPHYR_INCLUDE_LOGGING_LOG_BACKEND_MQTT_H_ */
        

Generated by: LCOV version 2.0-1