logging: Add dropped messages notification to backends
Extended backend interface to allow notifying backend that log messages has been dropped due to insufficient internal buffer size. Notification contains number of log messages dropped since last notification. It is optional for a backend to implement handler. Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
parent
f7f31b1e13
commit
a211c42a29
2 changed files with 40 additions and 1 deletions
|
@ -29,6 +29,7 @@ struct log_backend_api {
|
|||
void (*put)(const struct log_backend *const backend,
|
||||
struct log_msg *msg);
|
||||
|
||||
void (*dropped)(const struct log_backend *const backend, u32_t cnt);
|
||||
void (*panic)(const struct log_backend *const backend);
|
||||
void (*init)(void);
|
||||
};
|
||||
|
@ -94,7 +95,25 @@ static inline void log_backend_put(const struct log_backend *const backend,
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief Function for reconfiguring backend to panic mode.
|
||||
* @brief Notify backend about dropped log messages.
|
||||
*
|
||||
* Function is optional.
|
||||
*
|
||||
* @param[in] backend Pointer to the backend instance.
|
||||
* @param[in] cnt Number of dropped logs since last notification.
|
||||
*/
|
||||
static inline void log_backend_dropped(const struct log_backend *const backend,
|
||||
u32_t cnt)
|
||||
{
|
||||
assert(backend);
|
||||
|
||||
if (backend->api->dropped) {
|
||||
backend->api->dropped(backend, cnt);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reconfigure backend to panic mode.
|
||||
*
|
||||
* @param[in] backend Pointer to the backend instance.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue