server: keep request/access log out of the pySim output capture

The HTTP access log (log_message) and the --log-requests REQUEST/RESPONSE
lines wrote to the rebindable sys.stderr, so a concurrent card-free request
(the 2s /api/status poll) dropped its log line into the StringIO a card
command was capturing - corrupting file content read during a snapshot scan
(the access-log line appeared inside the file hex).

- Add _log_stderr(): write the request/access log to fd 2 directly (the same
  bypass the APDU tracer already uses), so it can never enter a capture.
  Route log_message, _log_req and _log_resp through it.
- Add _capture_app_output() context manager and deduplicate the six handlers
  (cardinfo/command/help/read/write/tree) that did the inline
  app.stdout/sys.stderr = out save/restore dance.

Bumps VERSION to 3.40.5 and the SW cache to simple-v491.
This commit is contained in:
catarrh committed 2026-11-08 12:51:13 +03:00
1 parent c4b64788b0
commit 011de4ae82
6 files changed
+172 -70

No files matched your search

+1 -1
View File
@@ -1,4 +1,4 @@
const CACHE = 'simple-v490';
const CACHE = 'simple-v491';
const URLS = [
'index.html',
'help.html',