-
Notifications
You must be signed in to change notification settings - Fork 193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
4847 logger singleton 3.1 #5119
Conversation
Previously, we used the openstudio::Singleton template to create the singleton named Logger. This implementation suffered a bug described in #4847, where the singleton was not global across the ScriptEngine DLL boundary. This change is a non templated implementation of Logger. The design is identical to openstudio::Singleton<LoggerSingleton>, but does not suffer the non-global issue. ref #4847
UtilitiesAPI.hpp needs to be included by SWIG so that the correct declspecs are used for the global logger. Previously, UTILITIES_API was just #define OPENSTUDIO_API, therefore the dll export decorator was not used.
8413d16
to
442cd38
Compare
src/utilities/core/Logger.hpp
Outdated
#include "Compare.hpp" // NOTE that this this is not needed for this header but so many compilation errors if I omit it | ||
// since other files transitively use Compare |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An unfortunate discovery. Cleaning up ours headers would be good, but that's not what I'm trying to achieve here.
src/utilities/core/Logger.hpp
Outdated
|
||
private: | ||
static std::shared_ptr<LoggerImpl> obj; | ||
std::shared_ptr<detail::Logger_Impl> m_impl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that the Logger is a Meyers singleton, I'm not sure whether the Logger_Impl class is really needed at all. But it feels familiar at least, and can allow us to shorten the public includes.
The dowside is that there's an extra method call for each (the forward to impl)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, I don't think we really need an Impl at all.
src/utilities/core/Logger.cpp
Outdated
Logger::Logger() : m_impl(std::shared_ptr<detail::Logger_Impl>(new detail::Logger_Impl())) {} | ||
|
||
Logger& Logger::instance() { | ||
static Logger instance; | ||
return instance; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Private constructor, and public ::instance()
CI Results for a13db45:
|
Pull request overview
I just want CI to run on it to I'm targeting develop for now, but really this is just a modification of #5110
Pull Request Author
src/model/test
)src/energyplus/Test
)src/osversion/VersionTranslator.cpp
)Labels:
IDDChange
APIChange
Pull Request - Ready for CI
so that CI builds your PRReview Checklist
This will not be exhaustively relevant to every PR.