fix: re-enabled dio logs (developer debug console)

This commit is contained in:
Aliaksei Tratseuski 2024-06-30 18:49:07 +04:00
parent f7f791cc0c
commit 4bda23eaf9
2 changed files with 15 additions and 10 deletions

View file

@ -4,7 +4,9 @@ import 'dart:io';
import 'package:dio/dio.dart';
import 'package:dio/io.dart';
// import 'package:pretty_dio_logger/pretty_dio_logger.dart';
import 'package:flutter/foundation.dart';
import 'package:pretty_dio_logger/pretty_dio_logger.dart';
import 'package:selfprivacy/config/config.dart';
import 'package:selfprivacy/config/get_it_config.dart';
import 'package:selfprivacy/logic/models/console_log.dart';
import 'package:selfprivacy/utils/app_logger.dart';
@ -14,12 +16,10 @@ abstract class RestApiMap {
Future<Dio> getClient({final BaseOptions? customOptions}) async {
final Dio dio = Dio(customOptions ?? (await options));
if (hasLogger) {
// dio.interceptors.add(
// PrettyDioLogger(
// logPrint: (final object) => log('$object'),
// ),
// );
if (hasLogger && config.shouldDebugPrint) {
dio.interceptors.add(
PrettyDioLogger(logPrint: (final object) => debugPrint('$object')),
);
}
dio.interceptors.add(ConsoleInterceptor());
dio.httpClientAdapter = IOHttpClientAdapter(
@ -34,10 +34,13 @@ abstract class RestApiMap {
dio.interceptors.add(
InterceptorsWrapper(
onError: (final DioException e, final ErrorInterceptorHandler handler) {
log('got dio error', error: e);
onError: (
final DioException exception,
final ErrorInterceptorHandler handler,
) {
log('got dio exception:', error: exception);
return handler.next(e);
return handler.next(exception);
},
),
);

View file

@ -4,6 +4,7 @@ import 'package:selfprivacy/config/config.dart';
class AppLogger {
const AppLogger({required this.name});
final String name;
// TODO: research other possible options, which could support both
@ -14,6 +15,7 @@ class AppLogger {
final StackTrace? stackTrace,
}) {
if (config.shouldDebugPrint) {
// TODO: could probably add UI logging for console_page
developer.log(
message,
error: error,