Add persistent split logging with rotation and retention
Summary
This PR adds persistent, host-mountable application logging with category-based files and time-based lifecycle controls.
What changed
- Added file-backed logger output to configurable
LOG_DIR(default/logsin production). - Added split log streams by category:
container-*.logapp-*.logaccess-*.logerror-*.logdebug-*.log
- Added rolling windows for log files using
LOG_ROTATION_DAYS(default: 30). - Added retention cleanup using
LOG_RETENTION_DAYS(default: 90). - Added request access logging middleware with method, path, status, bytes, duration, IP, and user-agent.
- Added
ACCESS_LOG_ENABLEDtoggle (default: true). - Updated Docker and compose config so
/logscan be bind-mounted for local collection. - Updated README env var docs for logging controls.
Why
Operators needed persistent logs mounted from the container, with bounded growth and clearer separation between operational streams for troubleshooting.
Notes
- Console logging remains unchanged.
- File logging can be disabled with
LOG_TO_FILE=false.
High-level PR Summary
This PR introduces persistent file-based logging with category-based log separation (container, app, access, error, debug), time-based rotation windows, and automatic retention cleanup. Log files are written to a configurable directory (LOG_DIR) that can be mounted from the host, and include HTTP access logging middleware. The system supports rotation based on LOG_ROTATION_DAYS (default 30 days) and prunes old logs after LOG_RETENTION_DAYS (default 90 days). Console logging remains unchanged, and file logging can be toggled via environment variables.
⏱️ Estimated Review Time: 30-90 minutes
💡 Review Order Suggestion
| Order | File Path |
|---|---|
| 1 | README.md |
| 2 | docker-compose.yml |
| 3 | Dockerfile |
| 4 | src/utils/logger.js |
| 5 | src/app.js |
Summary by CodeRabbit
-
New Features
- Short-link direct downloads, per-file download URLs in UI, upload cancel and improved upload flow
- Configurable public download domain, automated file retention, failed-upload retention/cleanup controls
- Enhanced logging options (file logging, rotation/retention) and updated site title
-
Bug Fixes
- Improved resumability and more reliable cleanup for failed/partial uploads
-
Documentation
- Expanded docs, examples, legal/terms display, and Docker/image references
Walkthrough
Adds short-link download routing, configurable public-domain and terms links, file retention and failed-upload cleanup, optional file-based and access logging, client-side upload cancellation with fail reporting, Docker/CI image and logging config updates, expanded docs, and tests for retention/upload/download behaviors.
Changes
| Cohort / File(s) | Summary |
|---|---|
Docker & Compose Dockerfile, docker-compose.yml |
Normalized Docker stage keywords (AS), added /logs creation and mount, switched to GHCR image, and introduced logging and PUBLIC_DOMAIN environment variables. |
Docs & Examples README.md, LOCAL_DEVELOPMENT.md, demo.md, docs/BIND_MOUNT_FIX.md, .env.example, LICENSE |
Branding and documentation updates; new env vars documented (PUBLIC_DOMAIN, TERMS_LINK, FILE_RETENTION, logging/cleanup toggles, etc.); README/license formatting edits. |
Server: core routing & API src/app.js, src/routes/files.js, src/routes/upload.js |
Added short-link download handler for non-reserved paths; generate downloadUrl in file/info/list responses; upload endpoints return richer file payloads, support /fail/:uploadId, and expose failed-upload cleanup APIs; refined PIN bypass for /download/*. |
Config & Utilities src/config/index.js, src/utils/logger.js, src/utils/cleanup.js, src/utils/fileUtils.js |
PUBLIC_DOMAIN and TERMS_LINK parsing/validation; logger gains optional file logging, rotation/retention and access logs; periodic file-retention cleanup added and exported; minor realpath error cleanup. |
Client / Frontend public/index.html, public/login.html, public/styles.css |
Injected TERMS_LINK-driven legal notices; added upload cancellation (AbortController), cancel/fail flows to call /api/upload/fail, render direct download links, and supporting CSS/ui changes. |
Tests test/*.test.js (auth.test.js, cleanup.test.js, files.test.js, upload.test.js, security.test.js) |
New retention cleanup tests; updated auth expectations; short-link download tests; strengthened upload/failure/retention assertions; sanitizer expectation adjusted. |
Build & CI .github/workflows/docker-publish.yml, package.json, src/scripts/pwa-manifest-generator.js |
CI gains verify job and GHCR publishing with branch/tag rules; npm test uses node --test; PWA manifest title default updated. |
Misc public/*, various docs |
UI/UX, CSS, and miscellaneous documentation and license text adjustments. |
Sequence Diagram(s)
sequenceDiagram
participant Client as Client (Browser)
participant Server as DumbDrop Server
participant FS as Filesystem
participant Cleanup as Retention Cleanup Scheduler
Client->>Server: GET /:shortPath
Server->>Server: resolve path -> config.uploadDir
Server->>Server: validate via isPathWithinUploadDir
Server->>FS: stat(path)
alt file exists & is regular file
FS-->>Server: file stream
Server->>Client: 200 + streamed file\nContent-Disposition header
else missing/invalid/reserved
Server->>Client: 403/404 or pass to other routing
end
Client->>Server: POST /api/upload/init and /api/upload/chunk
Server->>FS: write partials + metadata
Client->>Server: cancel -> POST /api/upload/fail/:uploadId
Server->>FS: set metadata.failedAt
Cleanup->>FS: periodic cleanupExpiredFiles checks retention
Cleanup->>FS: delete expired partials and metadata
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs
- DumbWareio/DumbDrop#72 — overlaps with cleanup scheduling and failed-upload retention logic (similar modifications to src/utils/cleanup.js and related tests).
Poem
🛠️ Short links hum, old partials fade away,
Logs curl up tidy, domains point where they may,
Clients cancel, servers mark and prune with care,
Terms show their notice, downloads bloom to share,
A neat little Drop, kept orderly and fair.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 9.09% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title accurately describes the main objective of the PR: adding persistent file-based logging with rotation and retention capabilities. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
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.