Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Dio prints debug message even if all LogInterceptors are turned off #2450

@hadjiprocopis

Description

@hadjiprocopis

Package

dio

Version

5.9.0

Operating-System

Linux, Android

Adapter

Default Dio

Output of flutter doctor -v

Dart Version

3.7.0

Steps to Reproduce

The following code will print 2 extraneous messages: *** Request *** and *** Response *** followed by the URI of the request.

I believe that this should not be happening because when if all LogInterceptors are set to false, then nothing should be logged unless it is an error (or, maybe, warning).

In order to see where this occurs, uncomment the line in the code below. For dio v5.9.0 the culprit is at lines 68 and 101 of file dio-5.9.0/lib/src/interceptors/log.dart.

This is the code to reproduce:

import 'package:dio/dio.dart';

void main() async {
final dio = Dio();
// I am cancelling all logging except error, I think:
dio.interceptors.add(LogInterceptor(
     // uncomment following line to locate the culprit code:
     // logPrint: (p){ print("XXXX Problem stacktrace "+StackTrace.current.toString()+": "+p.toString()); },
        responseBody: false,
        requestBody: false,
        requestHeader: false,
        responseHeader: false,
        request: false,
        error: true));

final response = await dio.get('https://example.com');

Expected Result

I expect nothing to be printed on the console.

Actual Result

It prints at the console this unecessary information:

*** Response *** and *** Request *** including the uri.

Metadata

Metadata

Assignees

No one assigned

    Labels

    h: need triageThis issue needs to be categorizeds: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions