Class LogInterceptor

java.lang.Object
com.algolia.internal.interceptors.LogInterceptor
All Implemented Interfaces:
okhttp3.Interceptor

public final class LogInterceptor extends Object implements okhttp3.Interceptor
An interceptor that facilitates HTTP logging based on the provided logging level. This class wraps around the HttpLoggingInterceptor to provide additional flexibility in log handling. It allows you to specify a custom Logger and a desired LogLevel.

Usage of this interceptor ensures that HTTP request and response details are logged according to the specified logging level. For example, setting the log level to LogLevel.BODY would result in detailed logging of both request and response bodies, while a level of LogLevel.BASIC would log request method, URL, and response status code.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface okhttp3.Interceptor

    okhttp3.Interceptor.Chain, okhttp3.Interceptor.Companion
  • Field Summary

    Fields inherited from interface okhttp3.Interceptor

    Companion
  • Constructor Summary

    Constructors
    Constructor
    Description
    LogInterceptor(Logger logger, LogLevel logLevel)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    okhttp3.Response
    intercept(okhttp3.Interceptor.Chain chain)
     
    okhttp3.logging.HttpLoggingInterceptor.Level
    toLevel(LogLevel logLevel)
     
    okhttp3.logging.HttpLoggingInterceptor.Logger
    toLogger(Logger logger)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LogInterceptor

      public LogInterceptor(Logger logger, LogLevel logLevel)
  • Method Details

    • toLogger

      public okhttp3.logging.HttpLoggingInterceptor.Logger toLogger(@Nonnull Logger logger)
    • toLevel

      public okhttp3.logging.HttpLoggingInterceptor.Level toLevel(@Nonnull LogLevel logLevel)
    • intercept

      @Nonnull public okhttp3.Response intercept(@Nonnull okhttp3.Interceptor.Chain chain) throws IOException
      Specified by:
      intercept in interface okhttp3.Interceptor
      Throws:
      IOException