Skip to content

format gateway logs as json, update express to v5 on gateway, add debug page to docs#1302

Open
joshunrau wants to merge 2 commits intoDouglasNeuroInformatics:mainfrom
joshunrau:debug-docs
Open

format gateway logs as json, update express to v5 on gateway, add debug page to docs#1302
joshunrau wants to merge 2 commits intoDouglasNeuroInformatics:mainfrom
joshunrau:debug-docs

Conversation

@joshunrau
Copy link
Collaborator

@joshunrau joshunrau commented Feb 28, 2026

Summary by CodeRabbit

  • Documentation
    • Added comprehensive debugging guide with detailed instructions for inspecting client-side and server-side logs, Docker-based commands for viewing server logs, techniques for filtering and analyzing JSON logs, and guidelines for reporting issues with proper diagnostic information.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 28, 2026

Walkthrough

This pull request introduces a centralized logging system using Pino throughout the gateway application. Dependencies are updated to support Express 5.x and Pino logging. All console logging is replaced with a new logger instance, and type casting is added for route parameters. Debugging documentation is included.

Changes

Cohort / File(s) Summary
Dependency Updates
apps/gateway/package.json
Express upgraded from ^4.21.2 to ^5.2.1; Pino family added (pino ^10.3.1, pino-http ^11.0.0, pino-pretty ^13.1.3); @types/express updated to ^5.0.6.
Logger Infrastructure
apps/gateway/src/logger.ts
New logger module created exporting a default Pino instance with custom write hook for pretty-printed JSON output to stdout.
Logging Integration
apps/gateway/src/middleware/error-handler.middleware.ts, apps/gateway/src/routers/api.router.ts, apps/gateway/src/routers/root.router.ts
Console.error replaced with logger.error; logger import added; req.params.id explicitly cast to string in route handlers.
Server Logging Refactor
apps/gateway/src/server/server.base.ts
Console.log and console.error replaced with logger.info and logger.error; PinoHttp integrated with shared logger instance; PinoPretty removed; wrapSerializers retained.
Documentation
docs/en/2-tutorials/2.2-debugging.md
New debugging guide covering client/server error differentiation, log inspection methods, Docker-based server logs, JSON filtering with jq, and issue reporting guidelines.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the three main changes: JSON log formatting, Express v5 upgrade, and debugging documentation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/gateway/package.json`:
- Line 32: Remove the unused dependency "pino-pretty" from package.json by
deleting its entry, update the lockfile (run npm install / yarn install) to
persist the change, and verify there are no imports/usages of "pino-pretty"
across the gateway codebase; confirm logger formatting remains handled by the
custom writer in apps/gateway/src/logger.ts and run the test/build to ensure no
breakage.

In `@docs/en/2-tutorials/2.2-debugging.md`:
- Line 10: The markdown heading levels jump to H3 causing MD001 failures; change
the "Client Logs" heading (currently "### Client Logs") and the two other
section headings mentioned (lines 14 and 28) to H2 (use "##") so heading levels
increment correctly; update each heading text only (replace leading "###" with
"##") and run the linter to confirm MD001 is resolved.
- Line 25: Update the jq filter in the example docker compose logs command so it
matches pino v10's numeric level values instead of string names: replace the
filter '.level == "ERROR"' with a numeric comparison that matches pino's ERROR
level (50) so the command "docker compose logs api --no-log-prefix --since 24h |
jq ..." actually selects error entries; ensure the example uses .level == 50 (or
an equivalent numeric comparison) in the docs snippet.

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 737f592 and b4c3d8d.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (7)
  • apps/gateway/package.json
  • apps/gateway/src/logger.ts
  • apps/gateway/src/middleware/error-handler.middleware.ts
  • apps/gateway/src/routers/api.router.ts
  • apps/gateway/src/routers/root.router.ts
  • apps/gateway/src/server/server.base.ts
  • docs/en/2-tutorials/2.2-debugging.md

"pino-pretty": "^11.2.2",
"pino": "^10.3.1",
"pino-http": "^11.0.0",
"pino-pretty": "^13.1.3",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for pino-pretty usage in gateway
rg -n "pino-pretty|PinoPretty" apps/gateway --type ts --type js

# Also check if it's imported in logger.ts or server.base.ts
echo "=== Checking logger.ts ==="
rg -n "pino-pretty" apps/gateway/src/logger.ts

echo "=== Checking server.base.ts ==="
rg -n "pino-pretty" apps/gateway/src/server.base.ts

# Check all files for require/import of pino-pretty
echo "=== All imports of pino-pretty ==="
rg -n "require.*pino-pretty|from.*pino-pretty|import.*pino-pretty" apps/gateway

Repository: DouglasNeuroInformatics/OpenDataCapture

Length of output: 265


🏁 Script executed:

#!/bin/bash
# Examine logger.ts to understand how formatting is configured
echo "=== Checking logger.ts for pino transport setup ==="
cat -n apps/gateway/src/logger.ts | head -100

Repository: DouglasNeuroInformatics/OpenDataCapture

Length of output: 388


Remove the unused pino-pretty dependency.

The package is declared in package.json but not imported or used anywhere in the gateway codebase. Logger formatting is already handled in apps/gateway/src/logger.ts via a custom write function that pretty-prints JSON output directly.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/gateway/package.json` at line 32, Remove the unused dependency
"pino-pretty" from package.json by deleting its entry, update the lockfile (run
npm install / yarn install) to persist the change, and verify there are no
imports/usages of "pino-pretty" across the gateway codebase; confirm logger
formatting remains handled by the custom writer in apps/gateway/src/logger.ts
and run the test/build to ensure no breakage.


When debugging, it’s important to distinguish between **client-side errors** (errors in the user’s browser) and **server-side errors** (errors from your backend services). Client-side issues appear in the browser console, while server-side issues are recorded by your running containers.

### Client Logs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix heading level increments to satisfy MD001.

Line 10 jumps to ### from body text; use ## section headings so heading levels increment correctly.

Proposed fix
-### Client Logs
+## Client Logs
@@
-### Server Logs
+## Server Logs
@@
-### Reporting Issues
+## Reporting Issues

Also applies to: 14-14, 28-28

🧰 Tools
🪛 markdownlint-cli2 (0.21.0)

[warning] 10-10: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3

(MD001, heading-increment)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/en/2-tutorials/2.2-debugging.md` at line 10, The markdown heading levels
jump to H3 causing MD001 failures; change the "Client Logs" heading (currently
"### Client Logs") and the two other section headings mentioned (lines 14 and
28) to H2 (use "##") so heading levels increment correctly; update each heading
text only (replace leading "###" with "##") and run the linter to confirm MD001
is resolved.

The API and Gateway logs are in JSON format, so you can filter and inspect them using jq. For example, to show only error-level logs from the last 24 hours:

```bash
docker compose logs api --no-log-prefix --since 24h | jq 'select(.level == "ERROR")'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# Check for pino usage and configuration in the gateway
find . -type f \( -name "package.json" -o -name "package-lock.json" -o -name "yarn.lock" \) | head -5

Repository: DouglasNeuroInformatics/OpenDataCapture

Length of output: 218


🏁 Script executed:

# Search for pino configuration or logger setup
rg "pino" --type json --type js --type ts -l | head -10

Repository: DouglasNeuroInformatics/OpenDataCapture

Length of output: 261


🌐 Web query:

pino v10 log level format output numeric or string values

💡 Result:

In Pino v10, the JSON log record’s level field is numeric by default (e.g. info30). [1] (dash0.com)

To output string levels instead, you have two common options:

  1. Enable useLevelLabels (outputs the level “as a string instead of integer”). [2] (jsdocs.io)

  2. Customize formatters.level(label, number) (default shape is { level: number }; you can return { level: label } to emit strings like "info"). [3] (jsdocs.io)

And if you’re using pino-pretty, it prints level labels in the pretty output (e.g. INFO). [4] (github.com)

Sources

  1. Dash0 guide showing default numeric level in Pino output. (dash0.com)
  2. Pino v10.3.1 API docs (useLevelLabels). (jsdocs.io)
  3. Pino v10.3.1 API docs (formatters.level(label, number), default { level: number }). (jsdocs.io)
  4. pino-pretty README example showing labeled level output (INFO). (github.com)

Citations:


🏁 Script executed:

cat apps/gateway/src/logger.ts

Repository: DouglasNeuroInformatics/OpenDataCapture

Length of output: 266


🏁 Script executed:

cat apps/gateway/package.json | grep -A 2 -B 2 "pino"

Repository: DouglasNeuroInformatics/OpenDataCapture

Length of output: 323


Update jq filter to use numeric error level.

The gateway uses pino v10 with default configuration, which emits numeric level values (50 for ERROR), not strings. The filter .level == "ERROR" will match nothing.

Proposed fix
-docker compose logs api --no-log-prefix --since 24h | jq 'select(.level == "ERROR")'
+docker compose logs api --no-log-prefix --since 24h | jq 'select(.level == 50)'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
docker compose logs api --no-log-prefix --since 24h | jq 'select(.level == "ERROR")'
docker compose logs api --no-log-prefix --since 24h | jq 'select(.level == 50)'
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/en/2-tutorials/2.2-debugging.md` at line 25, Update the jq filter in the
example docker compose logs command so it matches pino v10's numeric level
values instead of string names: replace the filter '.level == "ERROR"' with a
numeric comparison that matches pino's ERROR level (50) so the command "docker
compose logs api --no-log-prefix --since 24h | jq ..." actually selects error
entries; ensure the example uses .level == 50 (or an equivalent numeric
comparison) in the docs snippet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant