Skip to content
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 #5037 - Adjust log formatters for workflow (stdout + run.log) #5042

Merged
merged 7 commits into from
Nov 15, 2023

Conversation

jmarrec
Copy link
Collaborator

@jmarrec jmarrec commented Nov 15, 2023

Pull request overview

Pull Request Author

  • Model API Changes / Additions
  • Any new or modified fields have been implemented in the EnergyPlus ForwardTranslator (and ReverseTranslator as appropriate)
  • Model API methods are tested (in src/model/test)
  • EnergyPlus ForwardTranslator Tests (in src/energyplus/Test)
  • If a new object or method, added a test in NREL/OpenStudio-resources: Add Link
  • If needed, added VersionTranslation rules for the objects (src/osversion/VersionTranslator.cpp)
  • Verified that C# bindings built fine on Windows, partial classes used as needed, etc.
  • All new and existing tests passes
  • If methods have been deprecated, update rest of code to use the new methods

Labels:

  • If change to an IDD file, add the label IDDChange
  • If breaking existing API, add the label APIChange
  • If deemed ready, add label Pull Request - Ready for CI so that CI builds your PR

Review Checklist

This will not be exhaustively relevant to every PR.

  • Perform a Code Review on GitHub
  • Code Style, strip trailing whitespace, etc.
  • All related changes have been implemented: model changes, model tests, FT changes, FT tests, VersionTranslation, OS App
  • Labeling is ok
  • If defect, verify by running develop branch and reproducing defect, then running PR and reproducing fix
  • If feature, test running new feature, try creative ways to break it
  • CI status: all green or justified

@jmarrec jmarrec added component - CLI Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge. labs labels Nov 15, 2023
@jmarrec jmarrec requested a review from kbenne November 15, 2023 17:16
@jmarrec jmarrec self-assigned this Nov 15, 2023
Comment on lines +252 to +255
// TODO: ideally we want stdErr logger to always receive Error and Fatal
// and stdOut logger should receive all the others. This is definitely doable (cf LogSink::updateFilter) but now is not the time.
if (!m_show_stdout) {
openstudio::Logger::instance().standardOutLogger().disable();
} else if (workflowJSON.runOptions()->debug()) {
openstudio::Logger::instance().standardOutLogger().setLogLevel(Error); // Still show errors
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If --show-stdout not passed, still show Error and Fatals + leave a TODO to clean up later.

LogLevel targetLogLevel = oriLogLevel;
if (workflowJSON.runOptions()->debug() && oriLogLevel > Debug) {
targetLogLevel = Debug;
}

openstudio::Logger::instance().addTimeStampToLogger(); // Needed for run.log formatting
openstudio::Logger::instance().standardOutLogger().setFormatter(&standardFormatterWithStringSeverity);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Stdout: [Channel] <Debug> MSG

Comment on lines +280 to +282
constexpr bool use_workflow_gem_fmt = true;
constexpr bool include_channel = true; // or workflowJSON.runOptions()->debug();
logFile.useWorkflowGemFormatter(use_workflow_gem_fmt, include_channel);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Run.log: [11:12:13.123456 DEBUG] [Channel] MSG

Same as the Old Ruby CLI, but with the channel in addition

@jmarrec
Copy link
Collaborator Author

jmarrec commented Nov 15, 2023

Example:

  • When show stdout not passed, still show error.
  • See new formats!
$ $os_build2/Products/openstudio run --postprocess_only -w reportingmeasure.osw
[openstudio.measure.OSRunner] <Error> runner.registerError called
[openstudio.workflow.OSWorkflow] <Error> Found error in state 'ReportingMeasures' with message: 'Measure 'ReportingMeasureRegistersError' reported an error with [runner.registerError called]'
Failed to run workflow. Last Error:
  Found error in state 'ReportingMeasures' with message: 'Measure 'ReportingMeasureRegistersError' reported an error with [runner.registerError called]'

$ cat run/run.log
[18:38:06.159800 WARN] [openstudio.EpwFile] Header start day of the week and actual start day of the week do not match in EPW file '/Users/julien/Software/Others/OS-build2/resources/Examples/compact_osw/files/srrl_2013_amy.epw'. Data will be treated as typical (TMY)
[18:38:06.936419 ERROR] [openstudio.measure.OSRunner] runner.registerError called
[18:38:06.936646 ERROR] [openstudio.workflow.OSWorkflow] Found error in state 'ReportingMeasures' with message: 'Measure 'ReportingMeasureRegistersError' reported an error with [runner.registerError called]'

@kbenne kbenne merged commit f255bbb into develop Nov 15, 2023
4 of 6 checks passed
@kbenne kbenne deleted the 5030-extra-logger_format branch November 15, 2023 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component - CLI labs Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adjust LogSink log formatter
3 participants