88#define LOG_RPC_H_
99
1010#include <stddef.h>
11+ #include <stdint.h>
1112
1213/**
1314 * @file
@@ -21,7 +22,7 @@ extern "C" {
2122#endif
2223
2324/**
24- * nRF RPC logging level.
25+ * @brief nRF RPC logging level.
2526 */
2627enum log_rpc_level {
2728 LOG_RPC_LEVEL_NONE = 0 ,
@@ -32,55 +33,93 @@ enum log_rpc_level {
3233};
3334
3435/**
35- * Log history handler.
36+ * @brief Log history handler.
3637 *
3738 * The type of a callback function that is invoked for each received log message
3839 * while fetching the log history from the remote device.
3940 *
40- * @param level The message level, see @c log_rpc_level.
41+ * @param level The message level, see @ref log_rpc_level.
4142 * @param msg A pointer to the message payload.
4243 * @param msg_len The message payload length.
4344 */
4445typedef void (* log_rpc_history_handler_t )(enum log_rpc_level level , const char * msg ,
4546 size_t msg_len );
4647
48+ /** @brief Log history threshold reached handler.
49+ *
50+ * The type of a callback function that is invoked when the log history usage
51+ * threshold configured with @ref log_rpc_set_history_level has been reached for
52+ * the first time.
53+ */
54+ typedef void (* log_rpc_history_threshold_reached_handler_t )(void );
55+
4756/**
48- * Sets the log streaming verbosity level.
57+ * @brief Sets the log streaming verbosity level.
4958 *
5059 * The log streaming is the feature of nRF RPC logging that allows receiving log
5160 * messages as they are generated by the application running on the remote device.
5261 *
5362 * This function issues an nRF RPC command that configures the remote device to
5463 * stream log messages whose level is less than or equal to the specified level.
5564 *
56- * @param level Logging level, see @c log_rpc_level.
65+ * @param level Logging level, see @ref log_rpc_level.
5766 *
5867 * @retval 0 On success.
5968 * @retval -errno On failure.
6069 */
6170int log_rpc_set_stream_level (enum log_rpc_level level );
6271
6372/**
64- * Sets the log history verbosity level.
73+ * @brief Sets the log history verbosity level.
6574 *
6675 * The log history is the feature of nRF RPC logging that allows saving log
6776 * messages generated by the application running on the remote device into
6877 * a ring buffer, and then retrieving the log history when needed.
6978 *
70- * The function issues an nRF RPC command that configures the remote device to
79+ * This function issues an nRF RPC command that configures the remote device to
7180 * save log messages whose level is less than or equal to the specified level.
7281 *
73- * @param level Logging level, see @c log_rpc_level.
82+ * @param level Logging level, see @ref log_rpc_level.
7483 *
7584 * @retval 0 On success.
7685 * @retval -errno On failure.
7786 */
7887int log_rpc_set_history_level (enum log_rpc_level level );
7988
8089/**
81- * Fetches the log history.
90+ * @brief Gets the current history usage threshold.
91+ *
92+ * This function fetches the current history usage threshold.
93+ *
94+ * @returns The current history usage threshold in percentage.
95+ */
96+ uint8_t log_rpc_get_history_usage_threshold (void );
97+
98+ /**
99+ * @brief Sets the current history usage threshold.
100+ *
101+ * The log history is the feature of nRF RPC logging that allows saving log
102+ * messages generated by the application running on the remote device into
103+ * a ring buffer, and then retrieving the log history when needed.
104+ *
105+ * This function issues an nRF RPC command that requests the remote device to
106+ * emit an nRF RPC event when the ring buffer occupancy exceeds the requested
107+ * threshold for the first time after the threshold is set or the log history
108+ * is flushed.
109+ *
110+ * @param handler The handler that is invoked when the configured log
111+ * history usage threshold has been reached, see
112+ * @ref log_rpc_history_threshold_reached_handler_t.
113+ * @param threshold The history usage threshold in percentage (0 - 100).
114+ * Passing 0 disables this feature.
115+ */
116+ void log_rpc_set_history_usage_threshold (log_rpc_history_threshold_reached_handler_t handler ,
117+ uint8_t threshold );
118+
119+ /**
120+ * @brief Fetches the log history.
82121 *
83- * The function issues an nRF RPC command that starts the log history transfer
122+ * This function issues an nRF RPC command that starts the log history transfer
84123 * from the remote device. The @c handler callback function is invoked for each
85124 * received log message. Additionally, it is invoked with @c msg argument set to
86125 * NULL after all log messages have been received.
@@ -89,7 +128,7 @@ int log_rpc_set_history_level(enum log_rpc_level level);
89128 * still is in progress, the process is restarted from the current oldest
90129 * log message saved in the log history on the remote device.
91130 *
92- * @param handler History handler, see @c log_rpc_history_handler_t.
131+ * @param handler History handler, see @ref log_rpc_history_handler_t.
93132 *
94133 * @retval 0 On success.
95134 * @retval -errno On failure.
@@ -99,7 +138,7 @@ int log_rpc_fetch_history(log_rpc_history_handler_t handler);
99138/**
100139 * @brief Retrieves the crash log retained on the remote device.
101140 *
102- * The function issues an nRF RPC command to obtain the last crash log retained
141+ * This function issues an nRF RPC command to obtain the last crash log retained
103142 * on the remote device, and then it copies the received log chunk into the
104143 * specified buffer.
105144 *
@@ -120,7 +159,7 @@ int log_rpc_get_crash_log(size_t offset, char *buffer, size_t buffer_length);
120159/**
121160 * @brief Generates a log message on the remote device.
122161 *
123- * The function issues an nRF RPC command that requests the remote device to
162+ * This function issues an nRF RPC command that requests the remote device to
124163 * generate a log message with the given level. This function can be used to
125164 * test other functions of Logging over nRF RPC library.
126165 */
0 commit comments