-
Notifications
You must be signed in to change notification settings - Fork 1
refactor: improve logger initialization and configuration#83
Conversation
Important
Review skipped
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
- 🔍 Trigger a full review
✨ Finishing touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Post copyable unit tests in a comment
- Commit unit tests in branch
refactor_improve_logger_initialization_and_configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
- feat: add trusted origins configuration for auth #84 Graphite
- refactor: improve logger initialization and configuration #83 Graphite 👈 (View in Graphite)
- refactor: centralize environment variable handling with @tooling/env #82 Graphite
main
This stack of pull requests is managed by Graphite. Learn more about stacking.
9a07a34 to
dec9aab
Compare
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.
4 files reviewed, 1 comment
dec9aab to
dff01d7
Compare
Uh oh!
There was an error while loading. Please reload this page.
Greptile Overview
Greptile Summary
Refactored logger initialization from global configuration to per-app singleton pattern with lazy initialization. Each app now configures only the logger categories it needs, improving performance and reducing overhead.
configureLogger()/configureLoggerAsync()with newbuildLogger()function that configures specific categories per appLoggerCategory.EMAILand removed unusedLoggerCategory.SECURITYLoggerCategory.INNGESTconstantConfidence Score: 5/5
Important Files Changed
buildLogger()that configures specific categories per app, removed unused SECURITY category, added EMAIL categorygetLogger()with singleton pattern, async only on server-side (checksglobalThis.window)loggerimport togetLogger(LoggerCategory.EMAIL)for email-specific logging["inngest"]to useLoggerCategory.INNGESTconstantSequence Diagram
sequenceDiagram participant App as Application Entry Point participant Logger as app/shared/logger.ts participant Singleton as @init/utils/singleton participant Builder as @init/observability/logger participant LogTape as @logtape/logtape Note over App,LogTape: Before: Eager Global Initialization App->>Builder: configureLogger() / configureLoggerAsync() Builder->>LogTape: configure() / configureSync() with all categories Note over LogTape: All categories configured globally Note over App,LogTape: After: Lazy Per-App Initialization App->>Logger: import { logger } Logger->>Singleton: singleton("logger:app", buildLogger) alt First access Singleton->>Builder: buildLogger(categories, options) Builder->>Builder: Filter LOGGER_CONFIGS by categories Builder->>LogTape: configure() / configureSync() with filtered config LogTape-->>Builder: configured Builder->>LogTape: getLogger(defaultCategory) LogTape-->>Builder: logger instance Builder-->>Singleton: logger instance Singleton-->>Logger: cached logger else Subsequent access Singleton-->>Logger: cached logger (from globalThis.__remember_init) end Logger-->>App: logger instance