diff --git a/include/osmocom/core/fsm.h b/include/osmocom/core/fsm.h index f1080cde9..5bf5328ed 100644 --- a/include/osmocom/core/fsm.h +++ b/include/osmocom/core/fsm.h @@ -119,6 +119,34 @@ struct osmo_fsm_inst { void osmo_fsm_log_addr(bool log_addr); +/*! Log using FSM instance's context, on explicit logging subsystem and level. + * \param fi An osmo_fsm_inst. + * \param subsys A logging subsystem, e.g. DLGLOBAL. + * \param level A logging level, e.g. LOGL_INFO. + * \param fmt printf-like format string. + * \param args Format string arguments. + */ +#define LOGPFSMSL(fi, subsys, level, fmt, args...) \ + LOGPFSMSLSRC(fi, subsys, level, __FILE__, __LINE__, fmt, ## args) + +/*! Log using FSM instance's context, on explicit logging subsystem and level, + * and passing explicit source file and line information. + * \param fi An osmo_fsm_inst. + * \param subsys A logging subsystem, e.g. DLGLOBAL. + * \param level A logging level, e.g. LOGL_INFO. + * \param caller_file A string constant containing a source file path, like __FILE__. + * \param caller_line A number constant containing a source file line, like __LINE__. + * \param fmt printf-like format string. + * \param args Format string arguments. + */ +#define LOGPFSMSLSRC(fi, subsys, level, caller_file, caller_line, fmt, args...) \ + LOGPSRC(subsys, level, \ + caller_file, caller_line, \ + "%s{%s}: " fmt, \ + osmo_fsm_inst_name(fi), \ + (fi) ? osmo_fsm_state_name((fi)->fsm, (fi)->state) : "fi=NULL", ## args) + + /*! Log using FSM instance's context, on explicit logging level. * \param fi An osmo_fsm_inst. * \param level A logging level, e.g. LOGL_INFO. @@ -138,12 +166,8 @@ void osmo_fsm_log_addr(bool log_addr); * \param args Format string arguments. */ #define LOGPFSMLSRC(fi, level, caller_file, caller_line, fmt, args...) \ - LOGPSRC((fi) ? (fi)->fsm->log_subsys : DLGLOBAL, level, \ - caller_file, caller_line, \ - "%s{%s}: " fmt, \ - osmo_fsm_inst_name(fi), \ - (fi) ? osmo_fsm_state_name((fi)->fsm, (fi)->state) : "fi=NULL", \ - ## args) + LOGPFSMSLSRC(fi, (fi) ? (fi)->fsm->log_subsys : DLGLOBAL, level, \ + caller_file, caller_line, fmt, ## args) /*! Log using FSM instance's context. * The log level to log on is obtained from the FSM instance.