Skip to content

Commit

Permalink
Log path as a seperate structured logging field
Browse files Browse the repository at this point in the history
  • Loading branch information
hannesdejager committed Mar 11, 2022
1 parent 87c0fed commit 72aa59b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
12 changes: 12 additions & 0 deletions src/server/chancomms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ pub enum DataChanCmd {
},
}

impl DataChanCmd {
/// Returns the path the command pertains to
pub fn path(&self) -> Option<String> {
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)]
Expand Down
7 changes: 4 additions & 3 deletions src/server/datachan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -288,15 +289,15 @@ 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
)
} 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
)
Expand Down

0 comments on commit 72aa59b

Please sign in to comment.