This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Neels Hofmeyr gerrit-no-reply at lists.osmocom.orgReview at https://gerrit.osmocom.org/1430 fsm: add LOGPFSML to pass explicit logging level Provide one central LOGPFSML to print FSM information, take the FSM logging subsystem from the FSM instance but use an explicitly provided log level instead of the FSM's default level. Use to replace some, essentially, duplications of the LOGPFSM macro. In effect, the fsm_test's expected error changes, since the previous code dup for logging events used round braces to indicate the fi's state, while the central macro uses curly braces. Change-Id: If295fdabb3f31a0fd9490d1e0df57794c75ae547 --- M include/osmocom/core/fsm.h M src/fsm.c M tests/fsm/fsm_test.err 3 files changed, 12 insertions(+), 12 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/30/1430/1 diff --git a/include/osmocom/core/fsm.h b/include/osmocom/core/fsm.h index fba5497..026ed01 100644 --- a/include/osmocom/core/fsm.h +++ b/include/osmocom/core/fsm.h @@ -110,11 +110,14 @@ void osmo_fsm_log_addr(bool log_addr); -#define LOGPFSM(fi, fmt, args...) \ - LOGP((fi)->fsm->log_subsys, (fi)->log_level, "%s{%s}: " fmt, \ +#define LOGPFSML(fi, level, fmt, args...) \ + LOGP((fi)->fsm->log_subsys, level, "%s{%s}: " fmt, \ osmo_fsm_inst_name(fi), \ osmo_fsm_state_name((fi)->fsm, (fi)->state), ## args) +#define LOGPFSM(fi, fmt, args...) \ + LOGPFSML(fi, (fi)->log_level, fmt, ## args) + int osmo_fsm_register(struct osmo_fsm *fsm); void osmo_fsm_unregister(struct osmo_fsm *fsm); struct osmo_fsm_inst *osmo_fsm_inst_alloc(struct osmo_fsm *fsm, void *ctx, void *priv, diff --git a/src/fsm.c b/src/fsm.c index 9dc6b98..1db39f7 100644 --- a/src/fsm.c +++ b/src/fsm.c @@ -311,11 +311,9 @@ /* validate if new_state is a valid state */ if (!(st->out_state_mask & (1 << new_state))) { - LOGP(fsm->log_subsys, LOGL_ERROR, "%s(%s): transition to " - "state %s not permitted!\n", - osmo_fsm_inst_name(fi), - osmo_fsm_state_name(fsm, fi->state), - osmo_fsm_state_name(fsm, new_state)); + LOGPFSML(fi, LOGL_ERROR, + "transition to state %s not permitted!\n", + osmo_fsm_state_name(fsm, new_state)); return -EPERM; } @@ -376,10 +374,9 @@ } if (!((1 << event) & fs->in_event_mask)) { - LOGP(fsm->log_subsys, LOGL_ERROR, "%s(%s): Event %s not " - "permitted\n", osmo_fsm_inst_name(fi), - osmo_fsm_state_name(fsm, fi->state), - osmo_fsm_event_name(fsm, event)); + LOGPFSML(fi, LOGL_ERROR, + "Event %s not permitted\n", + osmo_fsm_event_name(fsm, event)); return -1; } fs->action(fi, event, data); diff --git a/tests/fsm/fsm_test.err b/tests/fsm/fsm_test.err index b9c738c..c9021bb 100644 --- a/tests/fsm/fsm_test.err +++ b/tests/fsm/fsm_test.err @@ -1,7 +1,7 @@ Checking FSM allocation [0;mTest FSM{NULL}: Allocated [0;mTest FSM{NULL}: Received Event 1 -[0;mTest FSM(NULL): Event 1 not permitted +[0;mTest FSM{NULL}: Event 1 not permitted [0;mTest FSM{NULL}: Received Event 0 [0;mTest FSM{NULL}: state_chg to ONE [0;mTest FSM{ONE}: Received Event 1 -- To view, visit https://gerrit.osmocom.org/1430 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If295fdabb3f31a0fd9490d1e0df57794c75ae547 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>