Skip to content

Commit 53fab4e

Browse files
committed
Support HTTY_ERROR_LOG environment variable for server-side debug logging.
1 parent 1725f03 commit 53fab4e

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

lib/async/htty/server.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,13 @@ def self.open(app = nil, input: $stdin, output: $stdout, error: $stderr, env: EN
4848
stream = ::Protocol::HTTY::Stream.new(original_input, original_output)
4949
input.reopen(File::NULL)
5050
output.reopen(File::NULL)
51-
error.reopen(File::NULL)
51+
52+
# Redirect error output to a file if specified, otherwise discard it:
53+
if error_log = ENV.fetch("HTTY_ERROR_LOG", nil)
54+
error.reopen(File.open(error_log, "a"))
55+
else
56+
error.reopen(File::NULL)
57+
end
5258

5359
Sync do |task|
5460
with_raw_terminal(original_input) do

releases.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased
44

55
- Suppress errors from `send_goaway` during connection cleanup to prevent shutdown exceptions from propagating.
6+
- Support redirecting server-side stderr to a file via the `HTTY_ERROR_LOG` environment variable, enabling debug logging without corrupting the HTTY byte stream.
67

78
## v0.3.0
89

0 commit comments

Comments
 (0)