Skip to content

Commit

Permalink
clearer debug messages
Browse files Browse the repository at this point in the history
  • Loading branch information
levkk committed Jan 26, 2025
1 parent 9526036 commit b566ddf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pgdog/src/backend/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ impl Server {
self.stats.state(State::Active);

#[cfg(debug_assertions)]
message.debug()?;
message.debug("→")?;

match self.stream().send(message).await {
Ok(sent) => self.stats.send(sent),
Expand Down Expand Up @@ -259,7 +259,7 @@ impl Server {
}

#[cfg(debug_assertions)]
message.debug()?;
message.debug("←")?;

Ok(message)
}
Expand Down
10 changes: 5 additions & 5 deletions pgdog/src/net/messages/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,27 +62,27 @@ pub trait Protocol: ToBytes + FromBytes {
Ok(Message::new(self.to_bytes()?))
}

fn debug(&self) -> Result<(), Error> {
fn debug(&self, direction: &str) -> Result<(), Error> {
let message = self.message()?;
match message.code() {
'd' => {
let copy_data = CopyData::from_bytes(message.to_bytes()?)?;
if let Some(xlog) = copy_data.xlog_data() {
debug!("{:#?}", xlog.payload());
debug!("{} {:#?}", direction, xlog.payload());
}
if let Some(meta) = copy_data.replication_meta() {
debug!("{:#?}", meta);
debug!("{} {:#?}", direction, meta);
}
}

'D' => {
let data_row = DataRow::from_bytes(message.to_bytes()?)?;
debug!("{:#?}", data_row);
debug!("{} {:#?}", direction, data_row);
}

'T' => {
let rd = RowDescription::from_bytes(message.to_bytes()?)?;
debug!("{:#?}", rd);
debug!("{} {:#?}", direction, rd);
}

_ => (),
Expand Down

0 comments on commit b566ddf

Please # to comment.