Skip to content
This repository has been archived by the owner on May 18, 2019. It is now read-only.

Commit

Permalink
add xml root element for logFormat=xml
Browse files Browse the repository at this point in the history
  • Loading branch information
Willi Braun authored and OpenModelica-Hudson committed Oct 27, 2016
1 parent c237c18 commit c98026b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions SimulationRuntime/c/simulation/simulation_runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,10 @@ int _main_SimulationRuntime(int argc, char**argv, DATA *data, threadData_t *thre

data->callback->callExternalObjectDestructors(data, threadData);
deInitializeDataStruc(data);

/* in case of xml log format close root element messages */
messagesCloseXMLroot();

fflush(NULL);
MMC_CATCH_INTERNAL(globalJumpBuffer)

Expand Down
22 changes: 22 additions & 0 deletions SimulationRuntime/c/util/omc_error.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,30 @@ void messageText(int type, int stream, int indentNext, char *msg, int subline, c
if (indentNext) level[stream]++;
}

static int printXMLrootNode = 0;

static void messagesXMLroot()
{
fputs("<messages>\n", stdout);
fflush(stdout);
}

void messagesCloseXMLroot()
{
if (printXMLrootNode){
fputs("</messages>\n", stdout);
fflush(stdout);
}
}

void messageXML(int type, int stream, int indentNext, char *msg, int subline, const int *indexes)
{
/* print xml root node */
if(!printXMLrootNode){
messagesXMLroot();
printXMLrootNode = 1;
}

printf("<message stream=\"%s\" type=\"%s\" text=\"", LOG_STREAM_NAME[stream], LOG_TYPE_DESC[type]);
printEscapedXML(msg);
if (indexes) {
Expand Down
1 change: 1 addition & 0 deletions SimulationRuntime/c/util/omc_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ extern int showAllWarnings;
extern char logBuffer[2048];

void setStreamPrintXML(int isXML);
void messagesCloseXMLroot();

#define ACTIVE_STREAM(stream) (useStream[stream])
#define ACTIVE_WARNING_STREAM(stream) (showAllWarnings || useStream[stream])
Expand Down

0 comments on commit c98026b

Please sign in to comment.