diff --git a/.gitmodules b/.gitmodules index 04b34e0..043a100 100644 --- a/.gitmodules +++ b/.gitmodules @@ -5,3 +5,12 @@ [submodule "vendor/discord-video-stream"] path = vendor/discord-video-stream url = https://github.com/dank074/discord-video-stream.git +[submodule "vendor/drizzle-orm"] + path = vendor/drizzle-orm + url = https://github.com/drizzle-team/drizzle-orm.git +[submodule "vendor/better-sqlite3"] + path = vendor/better-sqlite3 + url = https://github.com/WiseLibs/better-sqlite3.git +[submodule "vendor/node-datachannel"] + path = vendor/node-datachannel + url = https://github.com/Discord-RE/node-datachannel.git diff --git a/docs/superpowers/specs/2026-05-19-winston-logging-refactor-design.md b/docs/superpowers/specs/2026-05-19-winston-logging-refactor-design.md new file mode 100644 index 0000000..b0fc059 --- /dev/null +++ b/docs/superpowers/specs/2026-05-19-winston-logging-refactor-design.md @@ -0,0 +1,115 @@ +# Winston Logging Refactor Design + +## Goal + +Refactor project logging from Pino to Winston and clean up logging-related dependencies without changing application behavior. + +## Scope + +- Replace `pino` and `pino-pretty` with `winston`. +- Remove `pino-http` if no code still uses it. +- Keep logging access centralized in `src/logger.ts`. +- Preserve current exported logger API shape where practical: `logger` and `createChildLogger(context)`. +- Normalize log output and levels across the codebase. +- Avoid unrelated feature work or broad refactors. + +## Logging Architecture + +`src/logger.ts` remains the only logging entry point. It will create one Winston logger with npm levels: + +- `error` +- `warn` +- `info` +- `http` +- `verbose` +- `debug` +- `silly` + +`LOG_LEVEL` validation will be updated to accept these Winston standard levels. Default behavior stays environment-aware: development can log more detail, production stays concise. + +## Outputs + +Winston will write to: + +1. Console + - Pretty, colorized, timestamped output. + - Includes logger context, message, and metadata. +2. `logs/app.log` + - JSON format. + - Includes all logs at configured level and above. +3. `logs/error.log` + - JSON format. + - Includes error-level logs only. + +The logger should create the `logs/` directory at runtime if needed. `logs/` should be ignored by git. + +## Metadata and Error Handling + +Existing log calls mostly remain valid. `src/logger.ts` will format metadata centrally so individual call sites do not need custom serialization. + +Handled metadata shapes: + +- `{ error: err }` +- `{ err }` +- `{ reason }` +- extra plain objects used by existing log calls + +Errors should serialize with message, stack, name, code, statusCode, and any relevant enumerable fields. Non-error metadata should pass through without lossy conversion. + +## Code Changes + +Expected files: + +- `package.json` and lockfile: add `winston`, remove Pino packages that become unused. +- `src/logger.ts`: rewrite from Pino to Winston. +- `src/config.ts`: expand `LOG_LEVEL` schema. +- `.gitignore`: ignore `logs/` if missing. +- Logger call sites: update only if TypeScript or Winston format compatibility requires it. + +Known logger consumers include: + +- `src/index.ts` +- `src/webserver.ts` +- `src/middleware.ts` +- `src/voiceController.ts` +- `src/media/mediaController.ts` +- `src/media/screenShareController.ts` +- `src/moderation/broadcaster.ts` +- `src/moderation/messageCapture.ts` +- `src/streaming/transcoder.ts` + +Additional consumers should be found by grep during implementation. + +## Dependency Cleanup + +Remove packages only after confirming no imports remain: + +- `pino` +- `pino-pretty` +- `pino-http` + +Do not remove unrelated dependencies in this pass. + +## Testing and Verification + +Run: + +- `pnpm install` or equivalent lockfile update after dependency changes. +- `pnpm run typecheck` +- `pnpm run test` +- `pnpm run lint` + +Also verify log behavior with a short runtime command or startup check: + +- console output is readable and includes context. +- `logs/app.log` is created. +- `logs/error.log` is created when an error log occurs. + +## Success Criteria + +- No Pino imports remain. +- Winston is the only logging backend. +- Existing application logging calls compile. +- Log levels are consistent and configurable via `LOG_LEVEL`. +- Console and file logging both work. +- Tests, typecheck, and lint pass. diff --git a/vendor/better-sqlite3 b/vendor/better-sqlite3 new file mode 160000 index 0000000..d8885f9 --- /dev/null +++ b/vendor/better-sqlite3 @@ -0,0 +1 @@ +Subproject commit d8885f900cb626596e28a0ecd1b9d35bf15c7a0b diff --git a/vendor/drizzle-orm b/vendor/drizzle-orm new file mode 160000 index 0000000..48e5406 --- /dev/null +++ b/vendor/drizzle-orm @@ -0,0 +1 @@ +Subproject commit 48e5406027103a9fca6eb66417187c4a8b5c6aa3 diff --git a/vendor/node-datachannel b/vendor/node-datachannel new file mode 160000 index 0000000..46c65c8 --- /dev/null +++ b/vendor/node-datachannel @@ -0,0 +1 @@ +Subproject commit 46c65c88b7f76faf8fbece948e174e67b305ca04