mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2024-11-09 18:33:11 +00:00
fix: re-enabled dio logs (developer debug console)
This commit is contained in:
parent
f7f791cc0c
commit
4bda23eaf9
|
@ -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);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue