Improved logging with both compile and runtime level filtering

The device level debug will have to be removed and the debugging
can be based on this new logging structure which can tell where
an error (or debug output) occured whch the current implmentation
cannot.

The one limitation is the new macros cannot take a char* for the
format parameter. It must be an actual string literal because it
is concatenated with other strings.

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
Mark Charlebois
2015-06-17 13:28:27 -07:00
parent f56990a9ec
commit 1a8703ec1c
5 changed files with 129 additions and 81 deletions

View File

@@ -269,14 +269,15 @@ arming_state_transition(struct vehicle_status_s *status, ///< current vehicle s
}
if (ret == TRANSITION_DENIED) {
const char * str = "INVAL: %s - %s";
#define WARNSTR "INVAL: %s - %s"
/* only print to console here by default as this is too technical to be useful during operation */
warnx(str, state_names[status->arming_state], state_names[new_arming_state]);
warnx(WARNSTR, state_names[status->arming_state], state_names[new_arming_state]);
/* print to MAVLink if we didn't provide any feedback yet */
if (!feedback_provided) {
mavlink_log_critical(mavlink_fd, str, state_names[status->arming_state], state_names[new_arming_state]);
mavlink_log_critical(mavlink_fd, WARNSTR, state_names[status->arming_state], state_names[new_arming_state]);
}
#undef WARNSTR
}
return ret;