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

Enable Cpp logger under Windows and finalize it, ticket:4773 #2246

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion Compiler/Template/CodegenCpp.tpl
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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")
Copy link
Member

@adeas31 adeas31 Mar 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately this will not work. This will eventually become,
ifeq (""true"","true")
and will fail. Either get rid of quotes from the assignment or from the if condition. See also my comment on ticket:4773.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The quotes are removed with: #2252

USE_LOGGER_COMMAND=-DUSE_LOGGER:BOOL=ON
else
Expand Down