refactor: improve logger initialization and configuration #83
+114
−92
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.

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