mirror of
https://github.com/bitwarden/mobile
synced 2025-12-23 03:33:59 +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:
committed by
GitHub
parent
34d0ecf64b
commit
db7ca3b93e
@@ -1,4 +1,7 @@
|
||||
using Android;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Android;
|
||||
using Android.App;
|
||||
using Android.Content;
|
||||
using Android.OS;
|
||||
@@ -9,12 +12,6 @@ using Bit.Core;
|
||||
using Bit.Core.Abstractions;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Utilities;
|
||||
#if !FDROID
|
||||
using Microsoft.AppCenter.Crashes;
|
||||
#endif
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Bit.Droid.Autofill
|
||||
{
|
||||
@@ -28,6 +25,7 @@ namespace Bit.Droid.Autofill
|
||||
private IVaultTimeoutService _vaultTimeoutService;
|
||||
private IPolicyService _policyService;
|
||||
private IStateService _stateService;
|
||||
private LazyResolve<ILogger> _logger = new LazyResolve<ILogger>("logger");
|
||||
|
||||
public async override void OnFillRequest(FillRequest request, CancellationSignal cancellationSignal,
|
||||
FillCallback callback)
|
||||
@@ -84,9 +82,7 @@ namespace Bit.Droid.Autofill
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
#if !FDROID
|
||||
Crashes.TrackError(e);
|
||||
#endif
|
||||
_logger.Value.Exception(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,9 +156,7 @@ namespace Bit.Droid.Autofill
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
#if !FDROID
|
||||
Crashes.TrackError(e);
|
||||
#endif
|
||||
_logger.Value.Exception(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace Bit.Droid
|
||||
Window.AddFlags(Android.Views.WindowManagerFlags.Secure);
|
||||
}
|
||||
|
||||
#if !FDROID
|
||||
#if !DEBUG && !FDROID
|
||||
var appCenterHelper = new AppCenterHelper(_appIdService, _stateService);
|
||||
var appCenterTask = appCenterHelper.InitAsync();
|
||||
#endif
|
||||
|
||||
@@ -53,7 +53,8 @@ namespace Bit.Droid
|
||||
ServiceContainer.Resolve<IApiService>("apiService"),
|
||||
ServiceContainer.Resolve<IMessagingService>("messagingService"),
|
||||
ServiceContainer.Resolve<IPlatformUtilsService>("platformUtilsService"),
|
||||
ServiceContainer.Resolve<IDeviceActionService>("deviceActionService"));
|
||||
ServiceContainer.Resolve<IDeviceActionService>("deviceActionService"),
|
||||
ServiceContainer.Resolve<ILogger>("logger"));
|
||||
ServiceContainer.Register<IDeleteAccountActionFlowExecutioner>("deleteAccountActionFlowExecutioner", deleteAccountActionFlowExecutioner);
|
||||
|
||||
var verificationActionsFlowHelper = new VerificationActionsFlowHelper(
|
||||
@@ -87,7 +88,14 @@ namespace Bit.Droid
|
||||
|
||||
private void RegisterLocalServices()
|
||||
{
|
||||
ServiceContainer.Register<ILogService>("logService", new AndroidLogService());
|
||||
ServiceContainer.Register<INativeLogService>("nativeLogService", new AndroidLogService());
|
||||
#if FDROID
|
||||
ServiceContainer.Register<ILogger>("logger", new StubLogger());
|
||||
#elif DEBUG
|
||||
ServiceContainer.Register<ILogger>("logger", DebugLogger.Instance);
|
||||
#else
|
||||
ServiceContainer.Register<ILogger>("logger", Logger.Instance);
|
||||
#endif
|
||||
|
||||
// Note: This might cause a race condition. Investigate more.
|
||||
Task.Run(() =>
|
||||
|
||||
@@ -3,7 +3,7 @@ using System;
|
||||
|
||||
namespace Bit.Core.Services
|
||||
{
|
||||
public class AndroidLogService : ILogService
|
||||
public class AndroidLogService : INativeLogService
|
||||
{
|
||||
private static readonly string _tag = "BITWARDEN";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user