* @param[in] log_id The target buffer ID
* @param[in] prio The log's priority
* @param[in] tag The log's tag
- * @return 0 on success, else an error code.
+ * @return DLOG_ERROR_NONE on success, else an error code.
* @retval DLOG_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval DLOG_ERROR_NOT_PERMITTED Not permitted
*/
-static int dlog_should_log(log_id_t log_id, int prio, const char *tag)
+static int dlog_check_validity(log_id_t log_id, int prio, const char *tag)
{
- if (!debugmode && prio <= DLOG_DEBUG)
- return DLOG_ERROR_INVALID_PARAMETER;
-
if (!tag)
return DLOG_ERROR_INVALID_PARAMETER;
if (log_id <= LOG_ID_INVALID || LOG_ID_MAX <= log_id)
return DLOG_ERROR_INVALID_PARAMETER;
+ return DLOG_ERROR_NONE;
+}
+
+/**
+ * @brief Check log against limiter rules
+ * @details Checks whether the log passes current limiter rules
+ * @param[in] log_id The target buffer ID
+ * @param[in] prio The log's priority
+ * @param[in] tag The log's tag
+ * @return DLOG_ERROR_NONE on success, else an error code.
+ * @retval DLOG_ERROR_NOT_PERMITTED Not permitted
+ */
+static int dlog_check_limiter(log_id_t log_id, int prio, const char *tag)
+{
+ if (!debugmode && prio <= DLOG_DEBUG)
+ return DLOG_ERROR_NOT_PERMITTED;
+
if (dynamic_config)
__dynamic_config_update();
{
char buf[LOG_MAX_PAYLOAD_SIZE];
+ int ret = dlog_check_validity(log_id, prio, tag);
+ if (ret < 0)
+ return ret;
+
__dlog_init();
/* if limiter_apply_to_all_buffers config variable is set to 1,
* check_should_log value does not matter and the entry is always
* tested against all conditions, i.e. limiter rules
*/
- int ret = (limiter_apply_to_all_buffers ? true : check_should_log) ? dlog_should_log(log_id, prio, tag) : 0;
+ ret = (check_should_log || limiter_apply_to_all_buffers) ? dlog_check_limiter(log_id, prio, tag) : 0;
+
if (ret < 0)
- return ret;
+ return DLOG_ERROR_NONE;
vsnprintf(buf, sizeof buf, fmt, ap);