Skip to content

Commit

Permalink
Improve logging for configmap creation
Browse files Browse the repository at this point in the history
  • Loading branch information
garryod committed Jul 9, 2024
1 parent dc9ca57 commit d5a15f7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 31 deletions.
44 changes: 15 additions & 29 deletions sessionspaces/src/permissionables/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,37 +44,23 @@ pub struct Session {
pub end_date: PrimitiveDateTime,
}

#[derive(Debug)]
#[allow(dead_code, clippy::missing_docs_in_private_items)]
struct SessionSummary<'s> {
proposal_code: &'s str,
proposal_number: u32,
visit: u32,
instrument: Instrument,
members: usize,
gid: Option<&'s str>,
start_date: &'s PrimitiveDateTime,
end_date: &'s PrimitiveDateTime,
}

impl<'s> From<&'s Session> for SessionSummary<'s> {
fn from(value: &'s Session) -> Self {
Self {
proposal_code: &value.proposal_code,
proposal_number: value.proposal_number,
visit: value.visit,
instrument: value.instrument,
members: value.members.len(),
gid: value.gid.as_deref(),
start_date: &value.start_date,
end_date: &value.end_date,
}
}
}

impl Display for Session {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", SessionSummary::from(self))
write!(
f,
"{{ session: {}{}-{}, instrument: {}, members: {}, gid: {}, start: {}, end: {} }}",
self.proposal_code,
self.proposal_number,
self.visit,
self.instrument,
self.members.len(),
match &self.gid {
Some(gid) => gid.to_string(),
None => "None".to_string(),
},
self.start_date,
self.end_date
)
}
}

Expand Down
4 changes: 2 additions & 2 deletions sessionspaces/src/resources/config_maps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use tracing::{info, instrument};
/// The name to be given to the ConfigMap
const NAME: &str = "sessionspaces";

#[instrument(skip(k8s_client))]
#[instrument(skip(k8s_client, session))]
pub async fn create_configmap(
namespace: &str,
session: Session,
Expand Down Expand Up @@ -84,6 +84,6 @@ pub async fn create_configmap(
)
.await?;

info!("{NAME} ConfigMap created / updated for {namespace}");
info!("ConfigMap {NAME} created / updated for {namespace}");
Ok(())
}

0 comments on commit d5a15f7

Please sign in to comment.