1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-27 05:33:23 +00:00
Files
mobile/src/Core/Services/Logging/DebugLogger.cs
André Filipe da Silva Bispo 22c746543a PS-518 - Add setting to block AppCenter / Analytics - Mobile (#1905)
* PS-518 - Add setting to block AppCenter / Analytics - Mobile
- Added another entry into Settings page under the Others section
- Added prompt to ask user to enable / disable Crash Reports
- Added compilation tags to remove if the build is FDroid 

* PS-518 Add setting to block AppCenter / Analytics - Mobile
- Reduced FDroid compilation tags throughout the code
- Added Init, Enable and State methods to Logger
- Simplified SettingsPageViewModel Enable/Disable code

* PS-518 Add setting to block AppCenter / Analytics - Mobile
- Appcenter references were removed from App project, 
- Removed FDroid build.yml code that was deleting Appcenter packages from App.csproj

Co-authored-by: André Bispo <abispo@bitwarden.com>
2022-05-18 17:59:19 +01:00

58 lines
1.6 KiB
C#

#if !FDROID
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Bit.Core.Abstractions;
namespace Bit.Core.Services
{
public class DebugLogger : ILogger
{
static ILogger _instance;
public static ILogger Instance
{
get
{
if (_instance is null)
{
_instance = new DebugLogger();
}
return _instance;
}
}
protected DebugLogger()
{
}
public void Error(string message, IDictionary<string, string> extraData = null, [CallerMemberName] string memberName = "", [CallerFilePath] string sourceFilePath = "", [CallerLineNumber] int sourceLineNumber = 0)
{
var classAndMethod = $"{Path.GetFileNameWithoutExtension(sourceFilePath)}.{memberName}";
var filePathAndLineNumber = $"{Path.GetFileName(sourceFilePath)}:{sourceLineNumber}";
if (string.IsNullOrEmpty(message))
{
Debug.WriteLine($"Error found in: {classAndMethod})");
return;
}
Debug.WriteLine($"File: {filePathAndLineNumber}");
Debug.WriteLine($"Method: {memberName}");
Debug.WriteLine($"Message: {message}");
}
public void Exception(Exception ex) => Debug.WriteLine(ex);
public Task InitAsync() => Task.CompletedTask;
public Task<bool> IsEnabled() => Task.FromResult(true);
public Task SetEnabled(bool value) => Task.CompletedTask;
}
}
#endif