-
-
Notifications
You must be signed in to change notification settings - Fork 616
Inherit methodFactory
extensions from the parent to the child loggers.
#4809
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
Conversation
…getLevel());` This is the important part that actually registers the new methods.
methodFactory
extensions from the parent to the child loggers.
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.
Ummm... I think I understand the PR you referenced but I'm afraid I don't understand what's going on here, and the amount of casting through unknown and splicing of methods to other objects is terrifying. If we do this, it needs very heavy commenting!
@dbkr I found that |
… extension is in place.
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.
OK - thanks for the comments, I think it's a bit easier to see what's happening now.
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.
ok
I assume it is no longer an experiment? Could you update the PR description to reflect the current state, please? |
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.
looks generally good, a few clarifications though please
@toger5 the PR breaks the https://github.com/matrix-org/complement-crypto tests. These tests are run when the PR is put in the merge queue. |
@florianduros any idea how it breaks it? |
@toger5 Complement crypto runs the tests with an older version of loglevel (https://github.com/matrix-org/complement-crypto/blob/main/internal/api/js/js-sdk/yarn.lock#L226 |
@florianduros I think it makes sense to not use the |
20e178d
to
8e83e09
Compare
src/logger.ts
Outdated
childLogger.rebuild(); | ||
// childLogger.rebuild(); | ||
// TODO: As a stop-gap we use the deprecated method of rebuilding the logger | ||
// by setting the level. Complement Crypto uses an older version of loglevel. |
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.
Should we instead update the dependency in complement crypto?
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.
I have done this in: matrix-org/complement-crypto#173
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.
Thanks!
This fixes complement tests for: matrix-org/matrix-js-sdk#4809
8e83e09
to
54ecd1f
Compare
I reverted the last commit and we fix the issue with the updated complement-crypto PR. |
@@ -56,7 +56,7 @@ | |||
"bs58": "^6.0.0", | |||
"content-type": "^1.0.4", | |||
"jwt-decode": "^4.0.0", | |||
"loglevel": "^1.7.1", | |||
"loglevel": "^1.9.2", |
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.
FTR, I think this could equally be ^1.9.0
, since that's where .rebuild
was introduced, but I don't imagine it makes much difference in practice.
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.
It does not hurt to include the minor patches.
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.
It does not hurt to include the minor patches.
In this specific situation, I agree, but in general, that's not correct.
The reason it might hurt is that a downstream application may have specifically decided that they want to use 1.9.0 or 1.9.1, for some reason and pinned their dependencies accordingly. (For example, maybe it turns out that 1.9.2 introduces a regression in their application). There is no need for matrix-js-sdk to insist on 1.9.2, and as a general principle package.json
should list the earliest versions that we are compatible with.
Nevertheless that seems an unlikely scenario here. So I'm not going to insist you change it. But bear in mind for future :).
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.
LGTM
This fixes an issue where a log extension (a modification to the
methodFactory
) applied to a parent logger would ONLY be executed when logging with the parent but not on any of the children created withgetChild()
.This PR changes
getChild
to also inherit themethodFactory
from the parent.Checklist
public
/exported
symbols have accurate TSDoc documentation.