pub struct LoggingMiddleware { /* private fields */ }Expand description
Logging middleware that logs all messages.
§Examples
use pmcp::shared::{LoggingMiddleware, Middleware};
use pmcp::types::{JSONRPCRequest, RequestId};
use tracing::Level;
// Create logging middleware with different levels
let debug_logger = LoggingMiddleware::new(Level::DEBUG);
let info_logger = LoggingMiddleware::new(Level::INFO);
let default_logger = LoggingMiddleware::default(); // Uses DEBUG level
let mut request = JSONRPCRequest {
jsonrpc: "2.0".to_string(),
method: "tools.list".to_string(),
params: Some(serde_json::json!({"category": "development"})),
id: RequestId::from(456i64),
};
// Log at different levels
debug_logger.on_request(&mut request).await?;
info_logger.on_request(&mut request).await?;
default_logger.on_request(&mut request).await?;Implementations§
Trait Implementations§
Source§impl Debug for LoggingMiddleware
impl Debug for LoggingMiddleware
Source§impl Default for LoggingMiddleware
impl Default for LoggingMiddleware
Source§impl Middleware for LoggingMiddleware
impl Middleware for LoggingMiddleware
Source§fn on_request<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 mut JSONRPCRequest,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_request<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 mut JSONRPCRequest,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called before a request is sent.
Source§fn on_response<'life0, 'life1, 'async_trait>(
&'life0 self,
response: &'life1 mut JSONRPCResponse,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_response<'life0, 'life1, 'async_trait>(
&'life0 self,
response: &'life1 mut JSONRPCResponse,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called after a response is received.
Source§fn on_send<'life0, 'life1, 'async_trait>(
&'life0 self,
message: &'life1 TransportMessage,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_send<'life0, 'life1, 'async_trait>(
&'life0 self,
message: &'life1 TransportMessage,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called when a message is sent (any type).
Source§fn on_receive<'life0, 'life1, 'async_trait>(
&'life0 self,
message: &'life1 TransportMessage,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_receive<'life0, 'life1, 'async_trait>(
&'life0 self,
message: &'life1 TransportMessage,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called when a message is received (any type).
Auto Trait Implementations§
impl Freeze for LoggingMiddleware
impl RefUnwindSafe for LoggingMiddleware
impl Send for LoggingMiddleware
impl Sync for LoggingMiddleware
impl Unpin for LoggingMiddleware
impl UnwindSafe for LoggingMiddleware
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more