Repository navigation
Conversation
fshToFhir applied logLevel to the process-wide winston logger and never put it back, so a silent call left every later call muted.
Member
|
Thank you @cpruijsen for this PR. I apologize for the delay in reviewing it. I had a couple of large and complicated PRs that I had to get through first. I just merged one of them (#1637) today and I'm working my way through #1641 next. I hope to review the remaining PRs soon after that. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
fshToFhirsaves bothsilentandlevelon the process-wide winston logger, appliesoptions.logLevel, then restores them infinally, including on the invalid-logLevel return and when processing throws. AfterlogLevel: 'silent',logger.transports[0].silentstayed true, so a later call withlogLevel: 'error'(or with no option) still wrote nothing. AfterlogLevel: 'error',logger.levelstayed'error'for later calls that omitted the option. Errors and warnings in the returned object were already correct; only console logging leaked.'silent'is not a winston level. It sets the Console transport'ssilentflag, so restoringlogger.levelalone is not enough.The reporter's sequence in #1645 is the spec:
Restore both fields in
try/finallyrather than resetting toinfo/ not-silent at the start of each call and leaving the last call's settings on the logger (that restore stops a silent call from muting every other logger user in the process, and matches the existing save/restore pattern inwithDebugLoggingandrestoreMainLogger). Reset-at-start would also make sequentialfshToFhircalls independent, but it would leave the singleton muted (or aterror) after return. Happy to switch to reset-at-start if you wantlogger.levelto remain'error'after a call.Tests for during-call application use the existing
loadExternalDependenciesspy (it runs after logLevel is applied). New cases live in a#LoggerIsolationdescribe so they do not collide with the#EndToEndwork on #1642.Most of the
src/run/FshToFhir.tsdiff is re-indentation inside the newtry; hiding whitespace shows the actual change.Testing Instructions:
npm test -- test/run/FshToFhir.test.tsfshToFhir, run the three-call sequence from fshToFhir does not reset the logger between calls #1645 and confirm the second call is not silent and the third is back at the defaultinfolevel.npm test -- test/run/FshToFhir.test.ts(16 passed; 5 of them fail on master),tsc --noEmit, andprettier --check/eslinton the two changed files.Related Issue:
Fixes #1645