From 9721900b16e33536b9f5ad4ab9a49f4de2bbb276 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Tue, 30 Aug 2022 19:14:56 -0700 Subject: [PATCH] ssh: reduce some redundant logging around AcceptEnv just show it once at warn level and drop it to debug after that. --- wezterm-ssh/src/pty.rs | 27 ++++++++++++++++++++------- wezterm-ssh/src/session.rs | 1 + wezterm-ssh/src/sessioninner.rs | 1 + 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/wezterm-ssh/src/pty.rs b/wezterm-ssh/src/pty.rs index 0d91e08ff..5392ee9ad 100644 --- a/wezterm-ssh/src/pty.rs +++ b/wezterm-ssh/src/pty.rs @@ -228,13 +228,26 @@ impl crate::sessioninner::SessionInner { // Depending on the server configuration, a given // setenv request may not succeed, but that doesn't // prevent the connection from being set up. - log::warn!( - "ssh: setenv {}={} failed: {}. \ - Check the AcceptEnv setting on the ssh server side.", - key, - val, - err - ); + if !self.shown_accept_env_error { + log::warn!( + "ssh: setenv {}={} failed: {}. \ + Check the AcceptEnv setting on the ssh server side. \ + Additional errors with setting env vars in this \ + session will be logged at debug log level.", + key, + val, + err + ); + self.shown_accept_env_error = true; + } else { + log::debug!( + "ssh: setenv {}={} failed: {}. \ + Check the AcceptEnv setting on the ssh server side.", + key, + val, + err + ); + } } } } diff --git a/wezterm-ssh/src/session.rs b/wezterm-ssh/src/session.rs index e8674ab49..2c6fa070f 100644 --- a/wezterm-ssh/src/session.rs +++ b/wezterm-ssh/src/session.rs @@ -103,6 +103,7 @@ impl Session { next_file_id: 1, sender_read, session_was_dropped: false, + shown_accept_env_error: false, }; std::thread::spawn(move || inner.run()); Ok((Self { tx: session_sender }, rx_event)) diff --git a/wezterm-ssh/src/sessioninner.rs b/wezterm-ssh/src/sessioninner.rs index ff4b72e12..60db4d349 100644 --- a/wezterm-ssh/src/sessioninner.rs +++ b/wezterm-ssh/src/sessioninner.rs @@ -47,6 +47,7 @@ pub(crate) struct SessionInner { pub next_file_id: FileId, pub sender_read: FileDescriptor, pub session_was_dropped: bool, + pub shown_accept_env_error: bool, } impl Drop for SessionInner {