-
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
Fix #5164 - Unless --show-stdout, do not print any ExpandObjects / EnergyPlus messages #5169
Conversation
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.
This is mimic'ing the way openstudio classic run -w workflow.osw
would do it, completely silently.
IMHO this feels weird having zero output when it just works.
I'm thinking we should have --show-stdout
(and maybe --style-stdout
as being the default. and you could pass --no-show-stdout
to shush it, but that's only my opinion. @kbenne FYI
@@ -154,14 +154,30 @@ void OSWorkflow::runEnergyPlus() { | |||
// TODO: is this the right place /Do we want to do that if we chose epJSON? | |||
detailedTimeBlock("Saving IDF", [this, &inIDF] { workspace_->save(inIDF, true); }); | |||
|
|||
std::ofstream stdout_ofs(openstudio::toString(runDirPath / "stdout-energyplus"), std::ofstream::trunc); |
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.
Declare it higher, to trunc it first, because I'm going to pipe expand objects output to it as well.
detailedTimeBlock("Running ExpandObjects", [this, /*&cmd,*/ &result, &runDirPath, &runDirResults, &stdout_ofs] { | ||
// result = std::system(cmd.c_str()); | ||
namespace bp = boost::process; | ||
bp::ipstream is; | ||
std::string line; | ||
bp::child c(runDirResults.expandObjectsExe, bp::std_out > is); | ||
while (c.running() && std::getline(is, line)) { | ||
stdout_ofs << openstudio::ascii_trim_right(line) << '\n'; // Fix for windows... | ||
if (m_show_stdout) { | ||
fmt::print("{}\n", line); | ||
} | ||
} | ||
c.wait(); | ||
result = c.exit_code(); | ||
}); |
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.
Swallow the ExpandObjects stdout, otherwise you'll still get these
ExpandObjects Started.
No expanded file generated.
ExpandObjects Finished. Time: 0.021
std::string line; | ||
// bp::child c(cmd, bp::std_out > is); | ||
bp::child c(runDirResults.energyPlusExe, inIDF.filename(), bp::std_out > is); | ||
bp::child c(runDirResults.energyPlusExe, inIDF.filename(), (bp::std_out & bp::std_err) > is); |
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.
Pipe both stdout and stderr for E+, because the final EnergyPlus Completed Successfully.
is printed to stderr and we want to swallow it as well.
if (m_show_stdout) { | ||
if (m_style_stdout) { | ||
fmt::print("RunEnergyPlus: {} with ", status); | ||
fmt::print(fmt::fg(fmt::color::red), "{} Fatal Errors, ", errFile.fatalErrors().size()); | ||
fmt::print(fmt::fg(fmt::color::orange), "{} Severe Errors, ", errFile.severeErrors().size()); | ||
fmt::print(fmt::fg(fmt::color::yellow), "{} Warnings.", errFile.warnings().size()); | ||
fmt::print("\n"); | ||
} else { | ||
fmt::print("RunEnergyPlus: {} with {} Fatal Errors, {} Severe Errors, {} Warnings.\n", status, errFile.fatalErrors().size(), | ||
errFile.severeErrors().size(), errFile.warnings().size()); | ||
} | ||
} |
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.
Unless --show-stdout is passed: do not print the numer of fatal/severe/warnings
And do not style it (colors) unless --style-stdout
is passed.
auto* const logLevelOpt = app | ||
.add_option_function<LogLevel>( | ||
"-l,--loglevel", | ||
[](const LogLevel& level) { | ||
const auto loglLevelStr = logLevelStrs[static_cast<size_t>(level) - static_cast<size_t>(LogLevel::Trace)]; | ||
openstudio::Logger::instance().standardOutLogger().setLogLevel(level); | ||
LOG_FREE(Debug, "openstudio.CLI", "Setting Log Level to " << loglLevelStr << "(" << level << ")"); | ||
}, | ||
"LogLevel settings: One of {Trace, Debug, Info, Warn, Error, Fatal} [Default: Warn] Excludes: --verbose") | ||
->excludes(verboseOpt) | ||
->option_text("LEVEL") | ||
->transform(CLI::CheckedTransformer(logLevelMap, CLI::ignore_case)); |
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.
Don't print the "Setting Log Level to xx (n)" unless Debug or Trace.
@@ -140,7 +140,7 @@ openstudio::path XMLValidator::schematronToXslt(const openstudio::path& schemaPa | |||
saveXmlDocToFile(xsltPath, compiled); | |||
|
|||
xmlFreeDoc(compiled); | |||
LOG(Info, "Saved transformed XSLT Stylesheet at '" << toString(xsltPath) << "'."); | |||
LOG(Trace, "Saved transformed XSLT Stylesheet at '" << toString(xsltPath) << "'."); |
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.
e7f46c8 is optional, but I'm sick and tired of seeing too much verbosity in XMLValidator (which I'm responsible for, mind you), so I downgraded every Debug/Info message to a Trace.
You shouldn't have to think about what it's doing, and if you do need to debug something, just use Trace
CI Results for e7f46c8:
|
9920ad1
to
6b23cad
Compare
…ergyPlus messages
Thanks @jmarrec! |
Pull request overview
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.