1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-30 15:13:24 +00:00

BEEEP: Abstract and Centralize Logging (#1663)

* Abstracted App Center Logging into its own component, so that we can have it centralized in one place and we avoid checking for FDroid on all the places we want to use it

* Implemented the new logger where Crashes.TrackError was being used except on some specific cases

* Improved logging, added a debug logger and removed AppCenter to be used on DEBUG
This commit is contained in:
Federico Maccaroni
2022-03-02 14:15:16 -03:00
committed by GitHub
parent 34d0ecf64b
commit db7ca3b93e
32 changed files with 328 additions and 147 deletions

View File

@@ -1,9 +1,8 @@
using System;
using System.Threading.Tasks;
using System.Windows.Input;
#if !FDROID
using Microsoft.AppCenter.Crashes;
#endif
using Bit.Core.Abstractions;
using Bit.Core.Utilities;
using Xamarin.CommunityToolkit.ObjectModel;
using Xamarin.Forms;
@@ -23,14 +22,14 @@ namespace Bit.App.Controls
set => SetValue(MainFabProperty, value);
}
readonly LazyResolve<ILogger> _logger = new LazyResolve<ILogger>("logger");
public AccountSwitchingOverlayView()
{
InitializeComponent();
ToggleVisibililtyCommand = new AsyncCommand(ToggleVisibilityAsync,
#if !FDROID
onException: ex => Crashes.TrackError(ex),
#endif
onException: ex => _logger.Value.Exception(ex),
allowsMultipleExecutions: false);
}
@@ -110,9 +109,7 @@ namespace Bit.App.Controls
}
catch (Exception ex)
{
#if !FDROID
Crashes.TrackError(ex);
#endif
_logger.Value.Exception(ex);
}
}
@@ -133,9 +130,7 @@ namespace Bit.App.Controls
}
catch (Exception ex)
{
#if !FDROID
Crashes.TrackError(ex);
#endif
_logger.Value.Exception(ex);
}
}
}

View File

@@ -4,7 +4,6 @@ using System.Windows.Input;
using Bit.Core.Abstractions;
using Bit.Core.Models.View;
using Bit.Core.Utilities;
using Microsoft.AppCenter.Crashes;
using Xamarin.CommunityToolkit.ObjectModel;
using Xamarin.Forms;
@@ -16,15 +15,14 @@ namespace Bit.App.Controls
private readonly IMessagingService _messagingService;
public AccountSwitchingOverlayViewModel(IStateService stateService,
IMessagingService messagingService)
IMessagingService messagingService,
ILogger logger)
{
_stateService = stateService;
_messagingService = messagingService;
SelectAccountCommand = new AsyncCommand<AccountViewCellViewModel>(SelectAccountAsync,
#if !FDROID
onException: ex => Crashes.TrackError(ex),
#endif
onException: ex => logger.Exception(ex),
allowsMultipleExecutions: false);
}