import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';

class StreamDioLogInterceptor extends Interceptor {
  @override
  void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
    if (kDebugMode) {
      debugPrint('Stream Request: method[${options.method}],'
          ' url[${options.uri}],'
          ' headers[${options.headers}]');
    }
    handler.next(options);
  }

  @override
  void onError(DioException err, ErrorInterceptorHandler handler) {
    if (kDebugMode) {
      debugPrint('Stream Error: type[${err.type}],'
          ' message[${err.message}],'
          ' error[${err.error}],'
          ' stackTrace[${err.stackTrace}]');
    }
    handler.next(err);
  }

  @override
  void onResponse(Response response, ResponseInterceptorHandler handler) {
    if (kDebugMode) {
      debugPrint('Stream Response: header[${response.headers}],'
          ' statusCode[${response.statusCode}],'
          ' statusMessage[${response.statusMessage}]');
    }
    handler.next(response);
  }
}
