Skip to content

Commit

Permalink
Enable cassandra message logging
Browse files Browse the repository at this point in the history
  • Loading branch information
rukai committed Aug 22, 2022
1 parent c8c4799 commit 437b26f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions shotover-proxy/src/codec/cassandra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ impl CassandraCodec {
impl CassandraCodec {
fn encode_raw(&mut self, item: CassandraFrame, dst: &mut BytesMut) {
let buffer = item.encode().encode_with(self.compressor).unwrap();
tracing::debug!(
"outgoing cassandra message:\n{}",
pretty_hex::pretty_hex(&buffer)
);
if buffer.is_empty() {
info!("trying to send 0 length frame");
}
Expand All @@ -69,7 +65,7 @@ impl Decoder for CassandraCodec {
Ok(frame_len) => {
// Clear the read bytes from the FramedReader
let bytes = src.split_to(frame_len);
tracing::debug!(
tracing::error!(
"incoming cassandra message:\n{}",
pretty_hex::pretty_hex(&bytes)
);
Expand Down Expand Up @@ -124,11 +120,16 @@ impl Encoder<Messages> for CassandraCodec {
dst: &mut BytesMut,
) -> std::result::Result<(), Self::Error> {
for m in item {
let start = dst.len();
// TODO: always check if cassandra message
match m.into_encodable(MessageType::Cassandra)? {
Encodable::Bytes(bytes) => dst.extend_from_slice(&bytes),
Encodable::Frame(frame) => self.encode_raw(frame.into_cassandra().unwrap(), dst),
}
tracing::error!(
"outgoing cassandra message:\n{}",
pretty_hex::pretty_hex(&&dst[start..])
);
}
Ok(())
}
Expand Down

0 comments on commit 437b26f

Please sign in to comment.