From 72aa59bc3c9caf03463d45a318bd01bb425190f1 Mon Sep 17 00:00:00 2001 From: Hannes de Jager Date: Fri, 11 Mar 2022 13:58:27 +0100 Subject: [PATCH] Log path as a seperate structured logging field --- src/server/chancomms.rs | 12 ++++++++++++ src/server/datachan.rs | 7 ++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/server/chancomms.rs b/src/server/chancomms.rs index 2927a4e7..738024d3 100644 --- a/src/server/chancomms.rs +++ b/src/server/chancomms.rs @@ -38,6 +38,18 @@ pub enum DataChanCmd { }, } +impl DataChanCmd { + /// Returns the path the command pertains to + pub fn path(&self) -> Option { + match self { + DataChanCmd::Retr { path, .. } => Some(path.clone()), + DataChanCmd::Stor { path, .. } => Some(path.clone()), + DataChanCmd::List { path, .. } => path.clone(), + DataChanCmd::Nlst { path, .. } => path.clone(), + } + } +} + /// Messages that can be sent to the control channel loop. #[derive(Debug)] #[allow(dead_code)] diff --git a/src/server/datachan.rs b/src/server/datachan.rs index 4b5fd340..5a5b3abf 100644 --- a/src/server/datachan.rs +++ b/src/server/datachan.rs @@ -68,7 +68,8 @@ where slog::info!(self.logger, "Data channel abort received"); } DataChanMsg::ExternalCommand(command) => { - slog::info!(self.logger, "Data channel command received: {:?}", command); + let p = command.path().unwrap_or_default(); + slog::info!(self.logger, "Data channel command received: {:?}", command; "path" => p); self.execute_command(command).await; } } @@ -288,7 +289,7 @@ where if let Err(err) = socket.shutdown().await { slog::error!( logger, - "Couldn't close datachannel for ip ({}) that does not match the ip({}) of the control channel.\n{:?}", + "Couldn't close datachannel for IP ({}) that does not match the IP({}) of the control channel.\n{:?}", datachan_addr.ip(), controlcahn_ip, err @@ -296,7 +297,7 @@ where } else { slog::warn!( logger, - "Closing datachannel for ip ({}) that does not match the ip({}) of the control channel.", + "Closing datachannel for IP ({}) that does not match the IP({}) of the control channel.", datachan_addr.ip(), controlcahn_ip )