ThexXTURBOXx / catcher_2

Flutter error catching & handling plugin. Handles and reports exceptions in your app!
https://pub.dev/packages/catcher_2
Apache License 2.0
23 stars 26 forks source link

[Bug]: updating config causes everything to be logged twice #39

Closed MadsVETiSearch closed 13 hours ago

MadsVETiSearch commented 23 hours ago

Description

updating the config by Catcher2.getInstance().updateConfig causes duplicate lines when reporting to console/discord and so on

Minimal Reproduction

Steps to reproduce the behaviour:

  1. Use the following code:
import 'package:catcher_2/catcher_2.dart';
import 'package:flutter/material.dart';

final debugConfig1 = Catcher2Options(SilentReportMode(), [ConsoleHandler()]);
final debugConfig2 = Catcher2Options(
  SilentReportMode(),
  [
    ConsoleHandler(
      enableApplicationParameters: false,
      enableDeviceParameters: false,
    ),
  ],
);
void main() {
  Catcher2(
    debugConfig: debugConfig1,
    rootWidget: const MyApp(),
  );
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              ElevatedButton(onPressed: () => Catcher2.sendTestException(), child: const Text('1. throw exception')),
              const SizedBox(height: 20),
              ElevatedButton(onPressed: () => Catcher2.getInstance().updateConfig(debugConfig: debugConfig2), child: const Text('2. update config')),
              const SizedBox(height: 20),
              ElevatedButton(onPressed: () => Catcher2.sendTestException(), child: const Text('3. throw exception')),
            ],
          ),
        ),
      ),
    );
  }
}
  1. press buttons in this order
    • throw exception, check console,
    • update config
    • throw exception and check console

Exception or Error

flutter: [2024-11-18 11:36:40.285130 | Catcher 2 | WARNING] Screenshots path is empty. Screenshots won't be saved locally.
flutter: [2024-11-18 11:36:40.335811 | Catcher 2 | FINE] Catcher 2 configured successfully.
flutter: [2024-11-18 11:36:44.475572 | Catcher 2 | INFO] Setup localization lazily!
flutter: [2024-11-18 11:36:44.502955 | Catcher 2 | INFO] ============================== CATCHER 2 LOG ==============================
flutter: [2024-11-18 11:36:44.503442 | Catcher 2 | INFO] Crash occurred on 2024-11-18 11:36:44.501027
flutter: [2024-11-18 11:36:44.503862 | Catcher 2 | INFO]
flutter: [2024-11-18 11:36:44.504196 | Catcher 2 | INFO] ------- DEVICE INFO -------
flutter: [2024-11-18 11:36:44.504856 | Catcher 2 | INFO] model: iPhone
flutter: [2024-11-18 11:36:44.505121 | Catcher 2 | INFO] isPhysicalDevice: false
flutter: [2024-11-18 11:36:44.505237 | Catcher 2 | INFO] name: iPhone 14 Plus
flutter: [2024-11-18 11:36:44.505503 | Catcher 2 | INFO] identifierForVendor: AD237719-077E-47F3-AB11-E1279C7F0889
flutter: [2024-11-18 11:36:44.505587 | Catcher 2 | INFO] localizedModel: iPhone
flutter: [2024-11-18 11:36:44.505768 | Catcher 2 | INFO] systemName: iOS
flutter: [2024-11-18 11:36:44.506056 | Catcher 2 | INFO] utsnameVersion: Darwin Kernel Version 24.0.0: Tue Sep 24 23:36:26 PDT 2024; root:xnu-11215.1.12~1/RELEASE_ARM64_T8103
flutter: [2024-11-18 11:36:44.506189 | Catcher 2 | INFO] utsnameRelease: 24.0.0
flutter: [2024-11-18 11:36:44.506298 | Catcher 2 | INFO] utsnameMachine: iPhone14,8
flutter: [2024-11-18 11:36:44.506467 | Catcher 2 | INFO] utsnameNodename: Madss-MacBook-Pro.local
flutter: [2024-11-18 11:36:44.506563 | Catcher 2 | INFO] utsnameSysname: Darwin
flutter: [2024-11-18 11:36:44.506684 | Catcher 2 | INFO]
flutter: [2024-11-18 11:36:44.506962 | Catcher 2 | INFO] ------- APP INFO -------
flutter: [2024-11-18 11:36:44.507097 | Catcher 2 | INFO] environment: debug
flutter: [2024-11-18 11:36:44.507187 | Catcher 2 | INFO] version: 1.0.0
flutter: [2024-11-18 11:36:44.507264 | Catcher 2 | INFO] appName: Catcher Repord
flutter: [2024-11-18 11:36:44.507367 | Catcher 2 | INFO] buildNumber: 1
flutter: [2024-11-18 11:36:44.507458 | Catcher 2 | INFO] packageName: com.example.catcherRepord
flutter: [2024-11-18 11:36:44.508049 | Catcher 2 | INFO]
flutter: [2024-11-18 11:36:44.508145 | Catcher 2 | INFO] ---------- ERROR ----------
flutter: [2024-11-18 11:36:44.508244 | Catcher 2 | INFO] FormatException: Test exception generated by Catcher 2
flutter: [2024-11-18 11:36:44.508329 | Catcher 2 | INFO]
flutter: [2024-11-18 11:36:44.508536 | Catcher 2 | INFO] ------- STACK TRACE -------
flutter: [2024-11-18 11:36:44.508792 | Catcher 2 | INFO] #0      Catcher2.sendTestException (package:catcher_2/core/catcher_2.dart:695:5)
flutter: [2024-11-18 11:36:44.509853 | Catcher 2 | INFO] #1      MyApp.build.<anonymous closure> (package:catcher_repord/main.dart:33:56)
flutter: [2024-11-18 11:36:44.510347 | Catcher 2 | INFO] #2      _InkResponseState.handleTap (package:flutter/src/material/ink_well.dart:1170:21)
flutter: [2024-11-18 11:36:44.510437 | Catcher 2 | INFO] #3      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:351:24)
flutter: [2024-11-18 11:36:44.510533 | Catcher 2 | INFO] #4      TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:656:11)
flutter: [2024-11-18 11:36:44.510621 | Catcher 2 | INFO] #5      BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:313:5)
flutter: [2024-11-18 11:36:44.510737 | Catcher 2 | INFO] #6      BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:246:7)
flutter: [2024-11-18 11:36:44.510828 | Catcher 2 | INFO] #7      PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:703:9)
flutter: [2024-11-18 11:36:44.510921 | Catcher 2 | INFO] #8      PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:98:12)
flutter: [2024-11-18 11:36:44.510998 | Catcher 2 | INFO] #9      PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:143:9)
flutter: [2024-11-18 11:36:44.511154 | Catcher 2 | INFO] #10     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:633:13)
flutter: [2024-11-18 11:36:44.511233 | Catcher 2 | INFO] #11     PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:141:18)
flutter: [2024-11-18 11:36:44.511323 | Catcher 2 | INFO] #12     PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:127:7)
flutter: [2024-11-18 11:36:44.511620 | Catcher 2 | INFO] #13     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:501:19)
flutter: [2024-11-18 11:36:44.511767 | Catcher 2 | INFO] #14     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:481:22)
flutter: [2024-11-18 11:36:44.511901 | Catcher 2 | INFO] #15     RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:450:11)
flutter: [2024-11-18 11:36:44.511985 | Catcher 2 | INFO] #16     GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:426:7)
flutter: [2024-11-18 11:36:44.512914 | Catcher 2 | INFO] #17     GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:389:5)
flutter: [2024-11-18 11:36:44.513028 | Catcher 2 | INFO] #18     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:336:7)
flutter: [2024-11-18 11:36:44.513112 | Catcher 2 | INFO] #19     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:305:9)
flutter: [2024-11-18 11:36:44.513305 | Catcher 2 | INFO] #20     _invoke1 (dart:ui/hooks.dart:328:13)
flutter: [2024-11-18 11:36:44.513445 | Catcher 2 | INFO] #21     PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:442:7)
flutter: [2024-11-18 11:36:44.513530 | Catcher 2 | INFO] #22     _dispatchPointerDataPacket (dart:ui/hooks.dart:262:31)
flutter: [2024-11-18 11:36:44.513622 | Catcher 2 | INFO]
flutter: [2024-11-18 11:36:44.513790 | Catcher 2 | INFO] ======================================================================
flutter: [2024-11-18 11:36:44.514548 | Catcher 2 | INFO] ConsoleHandler successfully reported an error
flutter: [2024-11-18 11:36:46.231049 | Catcher 2 | WARNING] Screenshots path is empty. Screenshots won't be saved locally.
flutter: [2024-11-18 11:36:46.231049 | Catcher 2 | WARNING] Screenshots path is empty. Screenshots won't be saved locally.
flutter: [2024-11-18 11:36:48.043920 | Catcher 2 | INFO] Setup localization lazily!
flutter: [2024-11-18 11:36:48.043920 | Catcher 2 | INFO] Setup localization lazily!
flutter: [2024-11-18 11:36:48.067603 | Catcher 2 | INFO] ============================== CATCHER 2 LOG ==============================
flutter: [2024-11-18 11:36:48.067603 | Catcher 2 | INFO] ============================== CATCHER 2 LOG ==============================
flutter: [2024-11-18 11:36:48.068491 | Catcher 2 | INFO] Crash occurred on 2024-11-18 11:36:48.067486
flutter: [2024-11-18 11:36:48.068491 | Catcher 2 | INFO] Crash occurred on 2024-11-18 11:36:48.067486
flutter: [2024-11-18 11:36:48.068704 | Catcher 2 | INFO]
flutter: [2024-11-18 11:36:48.068704 | Catcher 2 | INFO]
flutter: [2024-11-18 11:36:48.068900 | Catcher 2 | INFO] ---------- ERROR ----------
flutter: [2024-11-18 11:36:48.068900 | Catcher 2 | INFO] ---------- ERROR ----------
flutter: [2024-11-18 11:36:48.069099 | Catcher 2 | INFO] FormatException: Test exception generated by Catcher 2
flutter: [2024-11-18 11:36:48.069099 | Catcher 2 | INFO] FormatException: Test exception generated by Catcher 2
flutter: [2024-11-18 11:36:48.069306 | Catcher 2 | INFO]
flutter: [2024-11-18 11:36:48.069306 | Catcher 2 | INFO]
flutter: [2024-11-18 11:36:48.069476 | Catcher 2 | INFO] ------- STACK TRACE -------
flutter: [2024-11-18 11:36:48.069476 | Catcher 2 | INFO] ------- STACK TRACE -------
flutter: [2024-11-18 11:36:48.069773 | Catcher 2 | INFO] #0      Catcher2.sendTestException (package:catcher_2/core/catcher_2.dart:695:5)
flutter: [2024-11-18 11:36:48.069773 | Catcher 2 | INFO] #0      Catcher2.sendTestException (package:catcher_2/core/catcher_2.dart:695:5)
flutter: [2024-11-18 11:36:48.069942 | Catcher 2 | INFO] #1      MyApp.build.<anonymous closure> (package:catcher_repord/main.dart:37:56)
flutter: [2024-11-18 11:36:48.069942 | Catcher 2 | INFO] #1      MyApp.build.<anonymous closure> (package:catcher_repord/main.dart:37:56)
flutter: [2024-11-18 11:36:48.070127 | Catcher 2 | INFO] #2      _InkResponseState.handleTap (package:flutter/src/material/ink_well.dart:1170:21)
flutter: [2024-11-18 11:36:48.070127 | Catcher 2 | INFO] #2      _InkResponseState.handleTap (package:flutter/src/material/ink_well.dart:1170:21)
flutter: [2024-11-18 11:36:48.070282 | Catcher 2 | INFO] #3      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:351:24)
flutter: [2024-11-18 11:36:48.070282 | Catcher 2 | INFO] #3      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:351:24)
flutter: [2024-11-18 11:36:48.070446 | Catcher 2 | INFO] #4      TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:656:11)
flutter: [2024-11-18 11:36:48.070446 | Catcher 2 | INFO] #4      TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:656:11)
flutter: [2024-11-18 11:36:48.070604 | Catcher 2 | INFO] #5      BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:313:5)
flutter: [2024-11-18 11:36:48.070604 | Catcher 2 | INFO] #5      BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:313:5)
flutter: [2024-11-18 11:36:48.070760 | Catcher 2 | INFO] #6      BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:246:7)
flutter: [2024-11-18 11:36:48.070760 | Catcher 2 | INFO] #6      BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:246:7)
flutter: [2024-11-18 11:36:48.070909 | Catcher 2 | INFO] #7      PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:703:9)
flutter: [2024-11-18 11:36:48.070909 | Catcher 2 | INFO] #7      PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:703:9)
flutter: [2024-11-18 11:36:48.071065 | Catcher 2 | INFO] #8      PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:98:12)
flutter: [2024-11-18 11:36:48.071065 | Catcher 2 | INFO] #8      PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:98:12)
flutter: [2024-11-18 11:36:48.071223 | Catcher 2 | INFO] #9      PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:143:9)
flutter: [2024-11-18 11:36:48.071223 | Catcher 2 | INFO] #9      PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:143:9)
flutter: [2024-11-18 11:36:48.071397 | Catcher 2 | INFO] #10     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:633:13)
flutter: [2024-11-18 11:36:48.071397 | Catcher 2 | INFO] #10     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:633:13)
flutter: [2024-11-18 11:36:48.071553 | Catcher 2 | INFO] #11     PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:141:18)
flutter: [2024-11-18 11:36:48.071553 | Catcher 2 | INFO] #11     PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:141:18)
flutter: [2024-11-18 11:36:48.071705 | Catcher 2 | INFO] #12     PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:127:7)
flutter: [2024-11-18 11:36:48.071705 | Catcher 2 | INFO] #12     PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:127:7)
flutter: [2024-11-18 11:36:48.071857 | Catcher 2 | INFO] #13     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:501:19)
flutter: [2024-11-18 11:36:48.071857 | Catcher 2 | INFO] #13     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:501:19)
flutter: [2024-11-18 11:36:48.072006 | Catcher 2 | INFO] #14     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:481:22)
flutter: [2024-11-18 11:36:48.072006 | Catcher 2 | INFO] #14     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:481:22)
flutter: [2024-11-18 11:36:48.072162 | Catcher 2 | INFO] #15     RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:450:11)
flutter: [2024-11-18 11:36:48.072162 | Catcher 2 | INFO] #15     RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:450:11)
flutter: [2024-11-18 11:36:48.072362 | Catcher 2 | INFO] #16     GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:426:7)
flutter: [2024-11-18 11:36:48.072362 | Catcher 2 | INFO] #16     GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:426:7)
flutter: [2024-11-18 11:36:48.072543 | Catcher 2 | INFO] #17     GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:389:5)
flutter: [2024-11-18 11:36:48.072543 | Catcher 2 | INFO] #17     GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:389:5)
flutter: [2024-11-18 11:36:48.072711 | Catcher 2 | INFO] #18     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:336:7)
flutter: [2024-11-18 11:36:48.072711 | Catcher 2 | INFO] #18     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:336:7)
flutter: [2024-11-18 11:36:48.072859 | Catcher 2 | INFO] #19     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:305:9)
flutter: [2024-11-18 11:36:48.072859 | Catcher 2 | INFO] #19     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:305:9)
flutter: [2024-11-18 11:36:48.073005 | Catcher 2 | INFO] #20     _invoke1 (dart:ui/hooks.dart:328:13)
flutter: [2024-11-18 11:36:48.073005 | Catcher 2 | INFO] #20     _invoke1 (dart:ui/hooks.dart:328:13)
flutter: [2024-11-18 11:36:48.073152 | Catcher 2 | INFO] #21     PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:442:7)
flutter: [2024-11-18 11:36:48.073152 | Catcher 2 | INFO] #21     PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:442:7)
flutter: [2024-11-18 11:36:48.073293 | Catcher 2 | INFO] #22     _dispatchPointerDataPacket (dart:ui/hooks.dart:262:31)
flutter: [2024-11-18 11:36:48.073293 | Catcher 2 | INFO] #22     _dispatchPointerDataPacket (dart:ui/hooks.dart:262:31)
flutter: [2024-11-18 11:36:48.073433 | Catcher 2 | INFO]
flutter: [2024-11-18 11:36:48.073433 | Catcher 2 | INFO]
flutter: [2024-11-18 11:36:48.073572 | Catcher 2 | INFO] ======================================================================
flutter: [2024-11-18 11:36:48.073572 | Catcher 2 | INFO] ======================================================================
flutter: [2024-11-18 11:36:48.073786 | Catcher 2 | INFO] ConsoleHandler successfully reported an error
flutter: [2024-11-18 11:36:48.073786 | Catcher 2 | INFO] ConsoleHandler successfully reported an error

Expected Behaviour

No duplicates in the output

Screenshots

No response

Additional context

No response

Device

iOS simulator (iphone 14)

OS

iOS 18

Flutter version

3.24.4

catcher_2 version

2.0.1

Checklist

ThexXTURBOXx commented 13 hours ago

Thanks for the bug report! I have released version 2.0.2, which fixes this issue :)