refactor: Unbind Logger from NodeJS module object (by type)
#3283
+7
−4
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.
This pull request updates the
Loggerutility to make its scoping more flexible and less dependent on NodeJSmoduleobjects.1 The changes allow the logger to be initialized with either a string or an object containing anid, making it easier to use in different contexts beyond just files or modules.It is backward compatible.
Changes
Logger scope improvements:
Loggerconstructor to accept ascopeparameter, which can be either a string or an object with anidproperty, instead of aNodeJS.Module. (packages/utils/src/Logger.ts)Logger.createNamestatic method to handle the newscopetype, extracting the identifier appropriately whether it's a string or an object. (packages/utils/src/Logger.ts)Scopetype alias for clarity and type safety. (packages/utils/src/Logger.ts)Future steps
moduleis a Node-specific object and is not available in ES and browser making the logger hard to use in other environments without a polyfill. Next steps would be to stop initializingLoggerwithmodule, esp. in files targetting multiple environments – subject for a separate PR.Footnotes
Extracted (with changes) from refactor [NET-1606]: Make
utilspackage work without polyfilling #3279. ↩