Commit 691ef70
refactor: Avoid NodeJS-specific
This pull request standardizes logger initialization throughout the
codebase by replacing the use of `new Logger(module)` with a more
descriptive string identifier for each module or class. This improves
the clarity of log messages and makes it easier to trace logs back to
their source components.
### Changes
**Logger initialization updates (all changes):**
* Replaced `new Logger(module)` with `new Logger('<ClassOrFileName>')`
in all relevant files across `autocertifier-client`,
`autocertifier-server`, `cdn-location`, and `dht` packages to ensure
consistent and descriptive logging.
* Replaced all occurrences of `loggerFactory.createLogger(module)` with
`loggerFactory.createLogger('<ClassOrFileName>')` in all relevant files
across the monorepo.
### Future steps
> [!NOTE]
> Because logger instances are created at the top level of each module,
simply importing the package into a host project will **eagerly
instantiate all associated loggers**, even if the corresponding exports
are never used.
1. Many modules currently instantiate a logger at import time (e.g. `new
Logger('Foo')`). This introduces a side effect during module evaluation,
which prevents effective tree-shaking of both the module itself and the
`Logger` implementation.
A future improvement would be to decouple logger creation from module
imports by moving initialization behind explicit factory functions or
lazy accessors. This would reduce import-time side effects and allow
unused modules (and the logger code) to be safely tree-shaken by the
bundler.
2. `Logger` was the key reason why we kept using (and polyfilling)
`module`. Consumers will be able to drop that env-specific "dependency"
from their setups soon.
---------
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: mondoreale <320066+mondoreale@users.noreply.github.com>module (use explicit logger scopes) (#3309)1 parent 8977cb8 commit 691ef70
File tree
168 files changed
+173
-175
lines changed- packages
- autocertifier-client/src
- autocertifier-server
- bin
- src
- cdn-location
- src
- test/integration
- cli-tools/bin
- dht
- src
- connection
- simulator
- webrtc
- websocket
- dht
- discovery
- recursive-operation
- routing
- store
- test
- benchmark
- hybrid-network-simulation
- integration
- geoip-location
- src
- test/helpers
- node
- src
- plugins
- autostaker
- consoleMetrics
- http
- mqtt
- operator
- storage
- subscriber
- websocket
- test
- integration/plugins
- operator
- storage
- smoke
- unit/plugins/operator
- proto-rpc/src
- sdk
- src
- contracts
- encryption
- subscribe
- ordering
- utils
- persistence
- test
- end-to-end
- test-utils
- test-utils/src
- trackerless-network
- src
- content-delivery-layer
- inspection
- neighbor-discovery
- plumtree
- proxy
- temporary-connection
- control-layer
- test/integration
- utils
- src
- test
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
168 files changed
+173
-175
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
0 commit comments