Class LoggingInterceptor

java.lang.Object
com.shri.restinpeace.interceptor.LoggingInterceptor
All Implemented Interfaces:
RequestInterceptor

public class LoggingInterceptor extends Object implements RequestInterceptor
Pre-built interceptor that logs a line before a request goes out and another when its response comes back, including the elapsed time. Sends to System.out::println by default; pass a Consumer to route lines to a real logger instead, without pulling a logging framework into this library's own dependencies.
  • Constructor Details

    • LoggingInterceptor

      public LoggingInterceptor()
      Logs to System.out.
    • LoggingInterceptor

      public LoggingInterceptor(Consumer<String> sink)
      Logs to a custom sink instead of System.out.
      Parameters:
      sink - receives each log line, e.g. a logger method reference
  • Method Details