-
Notifications
You must be signed in to change notification settings - Fork 222
4847 logger singleton 3.0 #5110
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
Changes from all commits
2d0a76c
659d01c
3984b2b
aad08ee
69c474b
c162c04
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,8 +30,8 @@ target_include_directories(pythonengine | |
| target_link_libraries( | ||
| pythonengine | ||
| PRIVATE | ||
| openstudiolib | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need this just because of the logger? isn't it part of the minimal?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes we need this because of the Logger and yes Logger is part of the minimal utilities target, however minimal is a different compiled unit and since we want a single global Logger we cannot have it implmented in multiple compiled units. In fact, I think we can do away with the minimal target after this. |
||
| openstudio_scriptengine | ||
| openstudio_utilities_minimal | ||
| CONAN_PKG::fmt | ||
| Python::Python | ||
| ) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| #include "../../scriptengine/ScriptEngine.hpp" | ||
| #include "../../utilities/core/Logger.hpp" | ||
|
|
||
| #include <gtest/gtest.h> | ||
|
|
||
| // cppcheck-suppress syntaxError | ||
| TEST(OpenStudioTest, LoggerGlobal) { | ||
| auto isEnabled = openstudio::Logger::instance().standardOutLogger().isEnabled(); | ||
| EXPECT_TRUE(isEnabled); | ||
|
|
||
| openstudio::ScriptEngineInstance pythonEngine("pythonengine", {}); | ||
| openstudio::ScriptEngineInstance rubyEngine("rubyengine", {}); | ||
|
|
||
| pythonEngine->exec("openstudio.Logger.instance().standardOutLogger().disable()"); | ||
| isEnabled = openstudio::Logger::instance().standardOutLogger().isEnabled(); | ||
| EXPECT_FALSE(isEnabled); | ||
|
|
||
| rubyEngine->exec("OpenStudio::Logger::instance().standardOutLogger().enable()"); | ||
| isEnabled = openstudio::Logger::instance().standardOutLogger().isEnabled(); | ||
| EXPECT_TRUE(isEnabled); | ||
|
|
||
| pythonEngine.reset(); | ||
| rubyEngine.reset(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ | |
| #endif | ||
|
|
||
|
|
||
| #define UTILITIES_API | ||
| %include <utilities/UtilitiesAPI.hpp> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ? We need to dllexport the swig stuff inside the swig lib now?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The swig generated code includes Logger.hpp which declares the Logger. We either need to link the Logger implementation into the swig generated code (like we have been doing with utilities minimal), or we need to use dllimport to signal that the implentation will come from a DLL. The problem with the former is that while linking to utilities minimal satisfies the linker, we had multiple implementations of the Logger floating around therefore it was not actually global. TLDR we need to declspec the Logger API everywhere that it is used. |
||
| #define MODEL_API | ||
| #define ENERGYPLUS_API | ||
|
|
||
|
|
||
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.
SHARED_OS_LIBS needed because?
Uh oh!
There was an error while loading. Please reload this page.
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.
The UtilitiesAPI preprocessor logic will not apply the required declspec if SHARED_OS_LIBS is not defined. That said, I think we could do away with entire SHARED_OS_LIBS definition with a bit of work. I don't think there is ever a configuration where we aren't using the openstudio.dll.