feat(cpex-scraper): add file logger for better debugging and tracing#4376
feat(cpex-scraper): add file logger for better debugging and tracing#4376faizkhairi wants to merge 2 commits intonusmodifications:masterfrom
Conversation
Add a lightweight file logger that writes timestamped lines to both stdout and a log file in the logs/ directory. The log directory is created automatically at runtime (already gitignored by root .gitignore). This matches the logging pattern used by the nus-v2 scraper, making it easier to debug and trace CPEx scraper runs. - Add src/logger.ts with createFileLogger() utility - Update src/index.ts to use the file logger instead of console
|
PR author is not in the allowed authors list. |
|
@faizkhairi is attempting to deploy a commit to the modsbot's projects Team on Vercel. A member of the Team first needs to authorize it. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4376 +/- ##
==========================================
+ Coverage 54.52% 56.39% +1.87%
==========================================
Files 274 308 +34
Lines 6076 6963 +887
Branches 1455 1680 +225
==========================================
+ Hits 3313 3927 +614
- Misses 2763 3036 +273 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Fix log directory path: '../logs' resolved to build/logs/ at runtime (inside gitignored build dir). Changed to '../../logs' to resolve to scrapers/cpex-scraper/logs/ (the scraper root) - Make close() return Promise to ensure all buffered data is flushed to disk before process exits - Await close() in both success and error paths in index.ts - Add error handler on write stream to prevent unhandled crash
|
Note on testing: I was unable to run the full CI suite locally (
The existing Let me know if you'd like me to add these tests. |
Summary
src/logger.ts) that writes timestamped lines to both stdout and a log filescrapers/cpex-scraper/logs/with formatcpex-YYYY-MM-DD.HH-mm-ss.log.gitignore)src/index.tsto use the file logger instead of the defaultconsolefsmodulePick<Console, 'log'>interface, soscraper.tsis unchangedRelated Issue
Closes #4371
Test Plan
pnpm --filter nusmods-cpex-scraper buildand verify compilation succeedslogs/directorypnpm --filter nusmods-cpex-scraper test)