pub trait Logger: Send + Sync + Clone + 'static {
    type Instant: Debug + Send + Sync + Copy;

    // Required methods
    fn on_connect(
        &self,
        _remote_addr: SocketAddr,
        _request: &HttpRequest,
        _t: TransportProtocol
    );
    fn on_request(&self, transport: TransportProtocol) -> Self::Instant;
    fn on_call(
        &self,
        method_name: &str,
        params: Params<'_>,
        kind: MethodKind,
        transport: TransportProtocol
    );
    fn on_result(
        &self,
        method_name: &str,
        success: bool,
        started_at: Self::Instant,
        transport: TransportProtocol
    );
    fn on_response(
        &self,
        result: &str,
        started_at: Self::Instant,
        transport: TransportProtocol
    );
    fn on_disconnect(
        &self,
        _remote_addr: SocketAddr,
        transport: TransportProtocol
    );
}
Expand description

Defines a logger specifically for WebSocket connections with callbacks during the RPC request life-cycle. The primary use case for this is to collect timings for a larger metrics collection solution.

See the ServerBuilder::set_logger for examples.

Required Associated Types§

source

type Instant: Debug + Send + Sync + Copy

Intended to carry timestamp of a request, for example std::time::Instant. How the trait measures time, if at all, is entirely up to the implementation.

Required Methods§

source

fn on_connect( &self, _remote_addr: SocketAddr, _request: &HttpRequest, _t: TransportProtocol )

Called when a new client connects

source

fn on_request(&self, transport: TransportProtocol) -> Self::Instant

Called when a new JSON-RPC request comes to the server.

source

fn on_call( &self, method_name: &str, params: Params<'_>, kind: MethodKind, transport: TransportProtocol )

Called on each JSON-RPC method call, batch requests will trigger on_call multiple times.

source

fn on_result( &self, method_name: &str, success: bool, started_at: Self::Instant, transport: TransportProtocol )

Called on each JSON-RPC method completion, batch requests will trigger on_result multiple times.

source

fn on_response( &self, result: &str, started_at: Self::Instant, transport: TransportProtocol )

Called once the JSON-RPC request is finished and response is sent to the output buffer.

source

fn on_disconnect(&self, _remote_addr: SocketAddr, transport: TransportProtocol)

Called when a client disconnects

Implementations on Foreign Types§

source§

impl Logger for ()

source§

impl<A, B> Logger for (A, B)where A: Logger, B: Logger,

§

type Instant = (<A as Logger>::Instant, <B as Logger>::Instant)

source§

fn on_connect( &self, remote_addr: SocketAddr, request: &HttpRequest, transport: TransportProtocol )

source§

fn on_request(&self, transport: TransportProtocol) -> Self::Instant

source§

fn on_call( &self, method_name: &str, params: Params<'_>, kind: MethodKind, transport: TransportProtocol )

source§

fn on_result( &self, method_name: &str, success: bool, started_at: Self::Instant, transport: TransportProtocol )

source§

fn on_response( &self, result: &str, started_at: Self::Instant, transport: TransportProtocol )

source§

fn on_disconnect(&self, remote_addr: SocketAddr, transport: TransportProtocol)

Implementors§