[PR #8704] [MERGED] fix(logging): debug prompts print with real line breaks #8758

Closed
opened 2026-11-07 17:39:29 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8704
Author: @SpicyMarinara
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/debug-console-line-breaks


📝 Commits (2)

  • 35d67c7 fix(logging): debug mode prompts print with real line breaks in the console
  • e3b252a fix(logging): image payloads, decision request bodies and the Termux .env keep line breaks

📊 Changes

42 files changed (+409 additions, -154 deletions)

View changed files

📝 .env.example (+3 -0)
📝 docker-compose.yml (+1 -0)
📝 docs/CONFIGURATION.md (+10 -1)
📝 docs/development/logging.md (+3 -1)
📝 e2e/decision-peek-report.e2e.ts (+3 -1)
📝 packages/client/src/components/chat/DecisionDebugPanel.tsx (+2 -2)
📝 packages/server/src/app.ts (+2 -2)
📝 packages/server/src/config/env-watcher.ts (+2 -0)
📝 packages/server/src/config/runtime-config.ts (+6 -0)
📝 packages/server/src/lib/logger.ts (+33 -8)
📝 packages/server/src/routes/encounter.routes.ts (+3 -3)
📝 packages/server/src/routes/gallery.routes.ts (+2 -2)
📝 packages/server/src/routes/game.routes.ts (+19 -27)
📝 packages/server/src/routes/generate/raw-route.ts (+2 -6)
📝 packages/server/src/routes/scene.routes.ts (+2 -2)
📝 packages/server/src/routes/sidecar.routes.ts (+3 -3)
📝 packages/server/src/services/advanced-memory.ts (+3 -3)
📝 packages/server/src/services/avatars/generation/mesh-rig.ts (+2 -2)
📝 packages/server/src/services/decision/sidecar-decision.backend.ts (+2 -2)
📝 packages/server/src/services/decision/system-one.client.ts (+3 -3)

...and 22 more files

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #8691

Why this change

With debug mode on, prompts and replies print in the server console without line breaks. There were two causes:

  1. Every launcher runs in production mode. start.sh, start.bat, start-termux.sh, the Dockerfile and docker-compose all export NODE_ENV=production. lib/logger.ts chose readable pino-pretty output only outside production, so the console a person reads printed raw JSON lines, and every line break showed as a literal \n.
  2. The structured dumps escaped their line breaks even in readable mode.
    • The provider request dumps used %j: Claude, Gemini, OpenAI-compatible, Game tool planning.
    • About 37 prompt dumps used JSON.stringify(...): raw generate, Professor Mari, scene planning, image captioning, advanced memory, decisions, combat, storyboards, video and image payloads.

The in-app Peek Prompt already kept line breaks. The Decision debug panel's request bodies did not.

What changed

  • lib/logger.ts: the log format follows where the output goes.
    • A terminal gets readable pino-pretty lines: pnpm dev, start.sh, start.bat and the Windows launcher window.
    • Pipes, files and docker logs stay one JSON object per line, as before.
    • New LOG_FORMAT=pretty|json overrides it. It's a restart-required key.
    • Termux reaches its terminal through tee, so it exports LOG_FORMAT=${LOG_FORMAT:-pretty} and reads it from .env.
    • Colours go only to a terminal, so the Termux session log stays free of escape codes.
  • New debugJson(value, replacer?), used with %s in place of %j and JSON.stringify in every structured debug dump.
    • It prints indented JSON whose escaped line breaks become real ones. A typed backslash-n stays text.
    • It renders only when the line is printed, so it costs nothing with debug off.
    • Existing redaction (secrets, blobs, data URIs) and level gating are unchanged.
  • Image generation dumps ([debug/image/*] final request payload, 13 call sites) and the Game asset request dump use it too.
  • DecisionDebugPanel's prepared request bodies now show their line breaks.
  • Docs:
    • docs/CONFIGURATION.md: a "Log format" subsection, and LOG_FORMAT in the restart list.
    • docs/development/logging.md: the format choice and debugJson.
    • .env.example and the docker-compose.yml comment.

Behaviour change worth noting: a production server whose output is a terminal now prints readable lines instead of JSON. Anyone who scraped JSON from a launcher terminal needs LOG_FORMAT=json. Piped, file and Docker output is unchanged.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

What the agent ran locally, rebased on staging:

  • node ./scripts/pnpm-runner.mjs check exits 0.
  • New regression debug-log-line-breaks. Real Claude and OpenAI generations, and an image generation, run with debug mode on, both in production mode to a pipe and in a terminal. It checks that the prompts print with real line breaks. It fails on unmodified staging.
  • Existing regressions that compared the raw %j argument now compare the rendered text: provider-compat, anthropic-safe-retry, card-field-generation. The PTY shutdown fixture pins LOG_FORMAT=json for its production pass.
  • Independent review: three defects, all fixed:
    • the image dumps;
    • the Decision panel bodies;
    • a source-text-only Termux check, replaced with a behaviour test.

For a human to verify:

  • On macOS or Linux, start with ./start.sh, turn on Settings → Advanced → Debug mode, and send a Roleplay message with a multi-line system prompt. Manually verify the terminal shows coloured, readable lines with the prompt's line breaks, not JSON with \n.
  • On Windows, start through the launcher. Manually verify the console shows readable lines and its colours render, not raw escape codes, in conhost and Windows Terminal.
  • On Android (Termux), start with start-termux.sh. Manually verify "Open Console" shows readable lines, and that ~/.marinara-engine/logs/server-*.log has no colour codes.
  • In Docker, manually verify docker logs still shows one JSON object per line by default, and readable lines with LOG_FORMAT=pretty.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

The English docs/CONFIGURATION.md and docs/development/logging.md are updated. The translations follow in #8701.

UI evidence (if applicable)

No visual change except the Decision debug panel's request bodies, which now wrap at their line breaks.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/8704 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/debug-console-line-breaks` --- ### 📝 Commits (2) - [`35d67c7`](https://github.com/Pasta-Devs/Marinara-Engine/commit/35d67c729bf052b27c59120824af411eec353f94) fix(logging): debug mode prompts print with real line breaks in the console - [`e3b252a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e3b252abd81b99cc52e6bb41bc69486bc804e141) fix(logging): image payloads, decision request bodies and the Termux .env keep line breaks ### 📊 Changes **42 files changed** (+409 additions, -154 deletions) <details> <summary>View changed files</summary> 📝 `.env.example` (+3 -0) 📝 `docker-compose.yml` (+1 -0) 📝 `docs/CONFIGURATION.md` (+10 -1) 📝 `docs/development/logging.md` (+3 -1) 📝 `e2e/decision-peek-report.e2e.ts` (+3 -1) 📝 `packages/client/src/components/chat/DecisionDebugPanel.tsx` (+2 -2) 📝 `packages/server/src/app.ts` (+2 -2) 📝 `packages/server/src/config/env-watcher.ts` (+2 -0) 📝 `packages/server/src/config/runtime-config.ts` (+6 -0) 📝 `packages/server/src/lib/logger.ts` (+33 -8) 📝 `packages/server/src/routes/encounter.routes.ts` (+3 -3) 📝 `packages/server/src/routes/gallery.routes.ts` (+2 -2) 📝 `packages/server/src/routes/game.routes.ts` (+19 -27) 📝 `packages/server/src/routes/generate/raw-route.ts` (+2 -6) 📝 `packages/server/src/routes/scene.routes.ts` (+2 -2) 📝 `packages/server/src/routes/sidecar.routes.ts` (+3 -3) 📝 `packages/server/src/services/advanced-memory.ts` (+3 -3) 📝 `packages/server/src/services/avatars/generation/mesh-rig.ts` (+2 -2) 📝 `packages/server/src/services/decision/sidecar-decision.backend.ts` (+2 -2) 📝 `packages/server/src/services/decision/system-one.client.ts` (+3 -3) _...and 22 more files_ </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Closes #8691 ## Why this change With debug mode on, prompts and replies print in the server console without line breaks. There were two causes: 1. **Every launcher runs in production mode.** start.sh, start.bat, start-termux.sh, the Dockerfile and docker-compose all export `NODE_ENV=production`. `lib/logger.ts` chose readable pino-pretty output only outside production, so the console a person reads printed raw JSON lines, and every line break showed as a literal `\n`. 2. **The structured dumps escaped their line breaks even in readable mode.** - The provider request dumps used `%j`: Claude, Gemini, OpenAI-compatible, Game tool planning. - About 37 prompt dumps used `JSON.stringify(...)`: raw generate, Professor Mari, scene planning, image captioning, advanced memory, decisions, combat, storyboards, video and image payloads. The in-app Peek Prompt already kept line breaks. The Decision debug panel's request bodies did not. ## What changed - **`lib/logger.ts`:** the log format follows where the output goes. - **A terminal** gets readable pino-pretty lines: `pnpm dev`, start.sh, start.bat and the Windows launcher window. - **Pipes, files and `docker logs`** stay one JSON object per line, as before. - **New `LOG_FORMAT=pretty|json`** overrides it. It's a restart-required key. - **Termux** reaches its terminal through `tee`, so it exports `LOG_FORMAT=${LOG_FORMAT:-pretty}` and reads it from `.env`. - **Colours** go only to a terminal, so the Termux session log stays free of escape codes. - **New `debugJson(value, replacer?)`**, used with `%s` in place of `%j` and `JSON.stringify` in every structured debug dump. - It prints indented JSON whose escaped line breaks become real ones. A typed backslash-n stays text. - It renders only when the line is printed, so it costs nothing with debug off. - Existing redaction (secrets, blobs, data URIs) and level gating are unchanged. - **Image generation dumps** (`[debug/image/*] final request payload`, 13 call sites) and the Game asset request dump use it too. - **`DecisionDebugPanel`'s** prepared request bodies now show their line breaks. - **Docs:** - `docs/CONFIGURATION.md`: a "Log format" subsection, and `LOG_FORMAT` in the restart list. - `docs/development/logging.md`: the format choice and `debugJson`. - `.env.example` and the `docker-compose.yml` comment. **Behaviour change worth noting:** a production server whose output is a terminal now prints readable lines instead of JSON. Anyone who scraped JSON from a launcher terminal needs `LOG_FORMAT=json`. Piped, file and Docker output is unchanged. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes What the agent ran locally, rebased on staging: - `node ./scripts/pnpm-runner.mjs check` exits 0. - **New regression `debug-log-line-breaks`.** Real Claude and OpenAI generations, and an image generation, run with debug mode on, both in production mode to a pipe and in a terminal. It checks that the prompts print with real line breaks. It fails on unmodified staging. - **Existing regressions** that compared the raw `%j` argument now compare the rendered text: provider-compat, anthropic-safe-retry, card-field-generation. The PTY shutdown fixture pins `LOG_FORMAT=json` for its production pass. - **Independent review:** three defects, all fixed: - the image dumps; - the Decision panel bodies; - a source-text-only Termux check, replaced with a behaviour test. For a human to verify: - On macOS or Linux, start with `./start.sh`, turn on Settings → Advanced → Debug mode, and send a Roleplay message with a multi-line system prompt. Manually verify the terminal shows coloured, readable lines with the prompt's line breaks, not JSON with `\n`. - On Windows, start through the launcher. Manually verify the console shows readable lines and its colours render, not raw escape codes, in conhost and Windows Terminal. - On Android (Termux), start with `start-termux.sh`. Manually verify "Open Console" shows readable lines, and that `~/.marinara-engine/logs/server-*.log` has no colour codes. - In Docker, manually verify `docker logs` still shows one JSON object per line by default, and readable lines with `LOG_FORMAT=pretty`. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) The English `docs/CONFIGURATION.md` and `docs/development/logging.md` are updated. The translations follow in #8701. ## UI evidence (if applicable) No visual change except the Decision debug panel's request bodies, which now wrap at their line breaks. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 17:39:29 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#8758
No description provided.