Skip to content

Conversation

@mondoreale
Copy link
Contributor

This pull request updates the Logger utility to make its scoping more flexible and less dependent on NodeJS module objects.1 The changes allow the logger to be initialized with either a string or an object containing an id, making it easier to use in different contexts beyond just files or modules.

It is backward compatible.

Changes

Logger scope improvements:

  • Changed the Logger constructor to accept a scope parameter, which can be either a string or an object with an id property, instead of a NodeJS.Module. (packages/utils/src/Logger.ts)
  • Updated the Logger.createName static method to handle the new scope type, extracting the identifier appropriately whether it's a string or an object. (packages/utils/src/Logger.ts)
  • Introduced the Scope type alias for clarity and type safety. (packages/utils/src/Logger.ts)

Future steps

  • module is 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 initializing Logger with module, esp. in files targetting multiple environments – subject for a separate PR.

Footnotes

  1. Extracted (with changes) from refactor [NET-1606]: Make utils package work without polyfilling #3279.

It can take a string, a module, or anything with an `id` now.
@mondoreale mondoreale requested a review from teogeb December 10, 2025 11:32
@github-actions github-actions bot added the utils label Dec 10, 2025
Copy link
Contributor

@teogeb teogeb left a comment

Choose a reason for hiding this comment

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

Good generalization. Maybe we don't need to introduce a separate term? Typically we create separate loggers for each module (e.g. class or component) and therefore that term is quite descriptive.

@mondoreale mondoreale requested a review from teogeb December 10, 2025 12:27
@mondoreale mondoreale merged commit 3187e70 into main Dec 10, 2025
23 checks passed
@mondoreale mondoreale deleted the unbind-logger-from-nodes-module branch December 10, 2025 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants