@@ -50,6 +50,7 @@ extern "C" {
5050#include "dmod_types.h"
5151#include <stdarg.h>
5252
53+
5354//==============================================================================
5455// FUNCTION PROTOTYPES
5556//==============================================================================
@@ -177,6 +178,34 @@ DMOD_BUILTIN_API(Dmod, 1.0, const char*, _GetCurrentModuleNameEx, ( const char*
177178 * @addtogroup DMOD_SAL_DEBUG
178179 * @{
179180 */
181+
182+ #ifdef DMOD_MODULE_NAME
183+ /**
184+ * @brief Get the effective log level for the current module
185+ *
186+ * On the first call the module context is looked up via
187+ * Dmod_GetModuleContext() using the module name supplied by
188+ * Dmod_GetCurrentModuleName(), and the result is cached in a static
189+ * variable. Subsequent calls skip the lookup entirely.
190+ *
191+ * A critical section guards the initialization to prevent concurrent
192+ * first-call races.
193+ */
194+ static inline Dmod_LogLevel_t Dmod_GetLogLevel (void )
195+ {
196+ static volatile Dmod_Context_t * s_ctx = NULL ;
197+
198+ Dmod_EnterCritical ();
199+ if ( s_ctx == NULL )
200+ {
201+ s_ctx = Dmod_GetModuleContext (Dmod_GetCurrentModuleName ());
202+ }
203+ Dmod_ExitCritical ();
204+
205+ return Dmod_GetModuleLogLevel (s_ctx );
206+ }
207+ #endif
208+
180209DMOD_BUILTIN_API ( Dmod , 1.0 , bool ,_CheckLogLevel , ( Dmod_LogLevel_t LogLevel ) );
181210DMOD_BUILTIN_API ( Dmod , 1.0 , int ,_Printf , ( const char * Format , ... ) );
182211DMOD_BUILTIN_API ( Dmod , 1.0 , int ,_FPrintf , ( void * File , const char * Format , ... ) );
0 commit comments