From: Ian Jackson Date: Sun, 10 Jan 2021 21:23:36 +0000 (+0000) Subject: cmdlistener: Better debug reporting of executed commands X-Git-Tag: otter-0.3.0~115 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=c0e1731055a0f7587f18cc71f5ed39c9b8a527fd;p=otter.git cmdlistener: Better debug reporting of executed commands Signed-off-by: Ian Jackson --- diff --git a/daemon/cmdlistener.rs b/daemon/cmdlistener.rs index 582f2211..3c74b3d6 100644 --- a/daemon/cmdlistener.rs +++ b/daemon/cmdlistener.rs @@ -862,17 +862,22 @@ impl CommandStream<'_> { use MgmtChannelReadError::*; let resp = match self.chan.read::() { Ok(cmd) => { - let cmd_s = log_enabled!(log::Level::Info) + let mut cmd_s = log_enabled!(log::Level::Info) .as_some_from(|| format!("{:?}", &cmd)) .unwrap_or_default(); + const MAX : usize = 200; + if cmd_s.len() > MAX-3 { + cmd_s.truncate(MAX-3); + cmd_s += ".."; + } match execute(&mut self, cmd) { Ok(resp) => { - info!("command connection {}: executed {:?}", + info!("command connection {}: executed {}", &self.desc, cmd_s); resp } Err(error) => { - info!("command connection {}: error {:?} from {:?}", + info!("command connection {}: error {:?} from {}", &self.desc, &error, cmd_s); MgmtResponse::Error { error } }