From 3385e4b0c491ddd914ce3c7c22c8cb6bef89fc9d Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sat, 2 Jun 2018 14:39:08 +0200 Subject: [PATCH] fsm: Change semantics of LOGPFSML() log-level The general idea about each osmo_fsm_instance having a separate log-level was to be able to selectively increase/show/enable logging for some FSM instances (e.g. of a particular subscriber) while maintaining normal logging verbosity for all other instances of the same FSM. The introduction of LOGPFSML() in Change-Id If295fdabb3f31a0fd9490d1e0df57794c75ae547 broke that idea, as it would use a compile-time log level, irrespective of the osmo_fsm_inst.log_level setting of the given instance. Let's combine the two: Use the explicit level stated at LOGPFSML(), _unless_ this instance has a higher log_level configured. This way, all FSMs should normally be created with osmo_fsm_inst.log_level == LOGL_DEBUG. At that point LOGPFSM() statements would be rendered at debug level, typically below the threshold of most logging configurations. Code that has explicit higher log levels like LOGPFSML(fi, LOGL_ERROR) would always be printed, as it is an error message. And if we now increase the osmo_fsm_inst.log_level, then even the normal LOGPFSM() statements would suddenly be logged at that higher level, selectively increasing log verbosity - like originally intended. Change-Id: I1820f04d0c6f5d5ff08eb95b8c0e88764534491a --- include/osmocom/core/fsm.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/osmocom/core/fsm.h b/include/osmocom/core/fsm.h index 67e00ad73..9e1062f53 100644 --- a/include/osmocom/core/fsm.h +++ b/include/osmocom/core/fsm.h @@ -120,7 +120,8 @@ struct osmo_fsm_inst { void osmo_fsm_log_addr(bool log_addr); #define LOGPFSML(fi, level, fmt, args...) \ - LOGP((fi)->fsm->log_subsys, level, "%s{%s}: " fmt, \ + LOGP((fi)->fsm->log_subsys, OSMO_MAX(level, (fi)->log_level), \ + "%s{%s}: " fmt, \ osmo_fsm_inst_name(fi), \ osmo_fsm_state_name((fi)->fsm, (fi)->state), ## args)