Skip to content

Commit 29b7d5a

Browse files
authored
Make it possible to silence LOG_ASSERT debug print for NLS/LS (#10668)
1 parent 9f0c21d commit 29b7d5a

File tree

1 file changed

+38
-9
lines changed

1 file changed

+38
-9
lines changed

OMCompiler/SimulationRuntime/c/util/omc_error.c

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -604,17 +604,35 @@ static inline jmp_buf* getBestJumpBuffer(threadData_t *threadData)
604604
}
605605
}
606606

607+
/**
608+
* @brief Variadic stream print and throw.
609+
*
610+
* Print message to LOG_ASSERT.
611+
*
612+
* @param threadData Thread data for throwing.
613+
* @param format Format string.
614+
* @param args Variadic argument list for format string
615+
*/
607616
void va_throwStreamPrint(threadData_t *threadData, const char *format, va_list args)
608617
{
609618
#if !defined(OMC_MINIMAL_LOGGING)
610-
char logBuffer[SIZE_LOG_BUFFER];
611-
vsnprintf(logBuffer, SIZE_LOG_BUFFER, format, args);
612-
messageFunction(LOG_TYPE_DEBUG, LOG_ASSERT, omc_dummyFileInfo, 0, logBuffer, 0, NULL);
619+
if (useStream[LOG_ASSERT]) {
620+
char logBuffer[SIZE_LOG_BUFFER];
621+
vsnprintf(logBuffer, SIZE_LOG_BUFFER, format, args);
622+
messageFunction(LOG_TYPE_DEBUG, LOG_ASSERT, omc_dummyFileInfo, 0, logBuffer, 0, NULL);
623+
}
613624
#endif
614625
threadData = threadData ? threadData : (threadData_t*)pthread_getspecific(mmc_thread_data_key);
615626
longjmp(*getBestJumpBuffer(threadData), 1);
616627
}
617628

629+
/**
630+
* @brief Print message to LOG_ASSERT and throw.
631+
*
632+
* @param threadData Thread data for throwing.
633+
* @param format Format string.
634+
* @param ... Additional arguments for format string.
635+
*/
618636
void throwStreamPrint(threadData_t *threadData, const char *format, ...)
619637
{
620638
#if !defined(OMC_MINIMAL_LOGGING)
@@ -628,15 +646,26 @@ void throwStreamPrint(threadData_t *threadData, const char *format, ...)
628646
#endif
629647
}
630648

649+
/**
650+
* @brief Print message with equation indices to LOG_ASSERT stream and throw.
651+
*
652+
* @param threadData Thread data for throwing.
653+
* @param info File info, can be omc_dummyFileInfo.
654+
* @param indexes Equation indices.
655+
* @param format Format string.
656+
* @param ... Additional arguments for format string.
657+
*/
631658
void throwStreamPrintWithEquationIndexes(threadData_t *threadData, FILE_INFO info, const int *indexes, const char *format, ...)
632659
{
633660
#if !defined(OMC_MINIMAL_LOGGING)
634-
char logBuffer[SIZE_LOG_BUFFER];
635-
va_list args;
636-
va_start(args, format);
637-
vsnprintf(logBuffer, SIZE_LOG_BUFFER, format, args);
638-
va_end(args);
639-
messageFunction(LOG_TYPE_DEBUG, LOG_ASSERT, info, 0, logBuffer, 0, indexes);
661+
if (useStream[LOG_ASSERT]) {
662+
char logBuffer[SIZE_LOG_BUFFER];
663+
va_list args;
664+
va_start(args, format);
665+
vsnprintf(logBuffer, SIZE_LOG_BUFFER, format, args);
666+
va_end(args);
667+
messageFunction(LOG_TYPE_DEBUG, LOG_ASSERT, info, 0, logBuffer, 0, indexes);
668+
}
640669
#endif
641670
threadData = threadData ? threadData : (threadData_t*)pthread_getspecific(mmc_thread_data_key);
642671
longjmp(*getBestJumpBuffer(threadData), 1);

0 commit comments

Comments
 (0)