Skip to content

Monkeypatch console.* calls on CI if we are asked to#11897

Merged
karrtikr merged 13 commits into
microsoft:logging-changes-and-drop-old-debuggerfrom
karrtikr:moneky
Jun 4, 2020
Merged

Monkeypatch console.* calls on CI if we are asked to#11897
karrtikr merged 13 commits into
microsoft:logging-changes-and-drop-old-debuggerfrom
karrtikr:moneky

Conversation

@karrtikr

@karrtikr karrtikr commented May 19, 2020

Copy link
Copy Markdown

@ericsnowcurrently I've not done monkeypatching for smoke tests because out directory isn't available while running it and we've to copy all of the logging code to test directory for it to work. Let me know if you think I should still do it, or if there's a better way.

For #11896

  • Pull request represents a single change (i.e. not fixing disparate/unrelated things in a single PR).
  • Title summarizes what is changing.
  • Has a news entry file (remember to thank yourself!).
  • Appropriate comments and documentation strings in the code.
  • Has sufficient logging.
  • Has telemetry for enhancements.
  • Unit tests & system/integration tests are added/updated.
  • Test plan is updated as appropriate.
  • package-lock.json has been regenerated by running npm install (if dependencies have changed).
  • The wiki is updated with any design decisions/details.

@ericsnowcurrently ericsnowcurrently left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is great work, @karrtikr. I think the approach you took is spot-on. I've left a few minor comments and noted one possible correctness issue. Otherwise, LGTM.

Comment thread src/client/logging/logger.ts
Comment thread src/test/multiRootTest.ts
Comment thread src/test/index.ts Outdated
Comment thread src/test/testLogger.ts
Comment thread src/test/testLogger.ts
Comment thread src/test/testLogger.ts
delete config.console;
// This is a separate logger that matches our config but
// does not do any console logging.
configureLogger(monkeyPatchLogger, config);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This means monkeyPatchLogger and globalLogger will each have a file handler writing to the same file. That is probably fine, though you may want to make sure it isn't a problem on Windows. (IIRC, on Windows only one process may have a file open at a time. I may be wrong though.)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

We use console.* calls only in tests before the extension activation. globalLogger is used after extension activation, so these 2 shouldn't conflict.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

As long as we're sure about console.log(), etc. Just keep in mind that any 3rd-party module (or VS Code itself) may also be calling console.log() at any time after the extension activates. Of course, it's a non-issue if having two logging handlers for the same file doesn't break (on Windows).

FWIW, my only objective was to make sure this had been considered and wasn't a problem (rather than to say there was a problem). 🙂

Comment thread src/test/testLogger.ts Outdated
Comment thread src/test/testLogger.ts
Comment thread news/3 Code Health/11896.md Outdated
@karrtikr karrtikr requested review from ericsnowcurrently and kimadeline and removed request for kimadeline June 2, 2020 18:18

@ericsnowcurrently ericsnowcurrently left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice work! Other than the question about GH Actions and the previous comment about closures, LGTM. I'm approving the PR under the assumption that you will address both. Thanks!

Comment thread build/ci/templates/test_phases.yml Outdated
Comment thread src/test/testLogger.ts Outdated
@karrtikr karrtikr removed the request for review from ericsnowcurrently June 4, 2020 13:36
@sonarqubecloud

sonarqubecloud Bot commented Jun 4, 2020

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@karrtikr karrtikr merged commit 7df168d into microsoft:logging-changes-and-drop-old-debugger Jun 4, 2020
@karrtikr karrtikr deleted the moneky branch June 4, 2020 17:30
karthiknadig pushed a commit to karthiknadig/vscode-python that referenced this pull request Jun 17, 2020
* Move console.* monkeypatching to src/test/testLogging.ts

* Use monkeypatching in all tests launched using testBootstrap.ts

* Use monkeypatching in single workspace and multiroot tests

* News entry

* Don't do monkeypatching for smoketests

* Modify gulp task to not delete 'out/client/logging' directory

* Undo smoke test ccheck

* Import only from ./out/client/logging in test logger

* Added comment

* More corrections

* Add comments

* Correct smoke tests

* Oops
ericsnowcurrently pushed a commit to ericsnowcurrently/vscode-python that referenced this pull request Jun 18, 2020
* Move console.* monkeypatching to src/test/testLogging.ts

* Use monkeypatching in all tests launched using testBootstrap.ts

* Use monkeypatching in single workspace and multiroot tests

* News entry

* Don't do monkeypatching for smoketests

* Modify gulp task to not delete 'out/client/logging' directory

* Undo smoke test ccheck

* Import only from ./out/client/logging in test logger

* Added comment

* More corrections

* Add comments

* Correct smoke tests

* Oops
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants