Skip to content

Commit

Permalink
ModelicaUtilities should output to the chosen log format
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@24385 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Feb 3, 2015
1 parent aa21603 commit 27f7b48
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
11 changes: 3 additions & 8 deletions SimulationRuntime/c/util/ModelicaUtilities.c
Expand Up @@ -43,8 +43,7 @@ void ModelicaMessage(const char* string) {
}

extern void ModelicaVFormatMessage(const char*string, va_list args) {
vfprintf(stdout, string, args);
fflush(stdout);
va_infoStreamPrint(LOG_STDOUT, 0, string, args);
}

void ModelicaFormatMessage(const char* string,...) {
Expand All @@ -56,16 +55,12 @@ void ModelicaFormatMessage(const char* string,...) {

MODELICA_NORETURN void OpenModelica_Simulation_ModelicaError(const char* string) MODELICA_NORETURNATTR;
void OpenModelica_Simulation_ModelicaError(const char* string) {
fputs(string, stderr);
fflush(stderr);
omc_throw(NULL);
throwStreamPrint(LOG_STDOUT, "%s", string);
}

MODELICA_NORETURN void OpenModelica_Simulation_ModelicaVFormatError(const char*string, va_list args) MODELICA_NORETURNATTR;
void OpenModelica_Simulation_ModelicaVFormatError(const char*string, va_list args) {
vfprintf(stderr, string, args);
fflush(stderr);
omc_throw(NULL);
va_throwStreamPrint(LOG_STDOUT, string, args);
}

MODELICA_NORETURN void (*OpenModelica_ModelicaError)(const char*) MODELICA_NORETURNATTR = OpenModelica_Simulation_ModelicaError;
Expand Down
9 changes: 9 additions & 0 deletions SimulationRuntime/c/util/omc_error.c
Expand Up @@ -314,6 +314,15 @@ void setStreamPrintXML(int isXML)
}

#define SIZE_LOG_BUFFER 2048
void va_infoStreamPrint(int stream, int indentNext, const char *format, va_list args)
{
if (useStream[stream]) {
char logBuffer[SIZE_LOG_BUFFER];
vsnprintf(logBuffer, SIZE_LOG_BUFFER, format, args);
messageFunction(LOG_TYPE_INFO, stream, indentNext, logBuffer, 0, NULL);
}
}

void infoStreamPrintWithEquationIndexes(int stream, int indentNext, const int *indexes, const char *format, ...)
{
if (useStream[stream]) {
Expand Down
1 change: 1 addition & 0 deletions SimulationRuntime/c/util/omc_error.h
Expand Up @@ -158,6 +158,7 @@ void setStreamPrintXML(int isXML);

extern void (*messageClose)(int stream);
extern void (*messageCloseWarning)(int stream);
extern void va_infoStreamPrint(int stream, int indentNext, const char *format, va_list ap);
extern void infoStreamPrint(int stream, int indentNext, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
extern void infoStreamPrintWithEquationIndexes(int stream, int indentNext, const int *indexes, const char *format, ...) __attribute__ ((format (printf, 4, 5)));
extern void warningStreamPrint(int stream, int indentNext, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
Expand Down

0 comments on commit 27f7b48

Please sign in to comment.