Skip to content

Commit

Permalink
Enable Cpp logger under Windows and finalize it, ticket:4773
Browse files Browse the repository at this point in the history
The finalizer shall flush buffers, e.g. of LoggerXMLTCP.

Belonging to [master]:
  - OpenModelica/OMCompiler#2246
  • Loading branch information
rfranke authored and OpenModelica-Hudson committed Mar 1, 2018
1 parent 67e62cb commit da270f8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Compiler/Template/CodegenCpp.tpl
Expand Up @@ -2381,13 +2381,14 @@ case SIMCODE(modelInfo=MODELINFO(__), makefileParams=MAKEFILE_PARAMS(__), simula
>>
%>

Logger::finalize();
return 0;

}
catch(ModelicaSimulationError& ex)
{
if(!ex.isSuppressed())
std::cerr << "Simulation stopped with error in " << error_id_string(ex.getErrorID()) << ": " << ex.what();
Logger::finalize();
return 1;
}
}
Expand Down
6 changes: 6 additions & 0 deletions SimulationRuntime/cpp/Core/Utils/extension/logger.cpp
Expand Up @@ -36,6 +36,12 @@ void Logger::initialize(LogSettings settings)
}
}

void Logger::finalize()
{
if (_instance != NULL)
delete _instance;
}

void Logger::writeInternal(std::string msg, LogCategory cat, LogLevel lvl,
LogStructure ls)
{
Expand Down
2 changes: 2 additions & 0 deletions SimulationRuntime/cpp/Include/Core/Utils/extension/logger.hpp
Expand Up @@ -55,6 +55,8 @@ class BOOST_EXTENSION_LOGGER_DECL Logger
initialize(LogSettings());
}

static void finalize();

static inline void write(std::string msg, LogCategory cat, LogLevel lvl)
{
if (_instance && _instance->isSet(cat, lvl))
Expand Down
2 changes: 1 addition & 1 deletion SimulationRuntime/cpp/Makefile.omdev.mingw
Expand Up @@ -81,7 +81,7 @@ else
PARALLEL_OUTPUT_COMMAND=-DUSE_PARALLEL_OUTPUT=OFF
endif

USE_LOGGER="false"
USE_LOGGER="true"
ifeq ("$(USE_LOGGER)","true")
USE_LOGGER_COMMAND=-DUSE_LOGGER:BOOL=ON
else
Expand Down

0 comments on commit da270f8

Please sign in to comment.