1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-12-28 17:18:23 +01:00

log service

This commit is contained in:
Kyle Spearrin 2019-06-03 12:52:46 -04:00
parent a5256a6491
commit b69304992f
5 changed files with 70 additions and 0 deletions

View File

@ -125,6 +125,7 @@
<Compile Include="Renderers\ExtendedListViewRenderer.cs" />
<Compile Include="Renderers\HybridWebViewRenderer.cs" />
<Compile Include="Services\AndroidPushNotificationService.cs" />
<Compile Include="Services\AndroidLogService.cs" />
<Compile Include="SplashActivity.cs" />
<Compile Include="MainApplication.cs" />
<Compile Include="MainActivity.cs" />

View File

@ -48,6 +48,7 @@ namespace Bit.Droid
private void RegisterLocalServices()
{
ServiceContainer.Register<ILogService>("logService", new AndroidLogService());
ServiceContainer.Register("settingsShim", new App.Migration.SettingsShim());
if(App.Migration.MigrationHelpers.NeedsMigration())
{

View File

@ -0,0 +1,30 @@
using Bit.Core.Abstractions;
using System;
namespace Bit.Core.Services
{
public class AndroidLogService : ILogService
{
private static readonly string _tag = "BITWARDEN";
public void Debug(string message)
{
Android.Util.Log.WriteLine(Android.Util.LogPriority.Debug, _tag, message);
}
public void Info(string message)
{
Android.Util.Log.WriteLine(Android.Util.LogPriority.Info, _tag, message);
}
public void Warning(string message)
{
Android.Util.Log.WriteLine(Android.Util.LogPriority.Warn, _tag, message);
}
public void Error(string message)
{
Android.Util.Log.WriteLine(Android.Util.LogPriority.Error, _tag, message);
}
}
}

View File

@ -0,0 +1,10 @@
namespace Bit.Core.Abstractions
{
public interface ILogService
{
void Debug(string message);
void Error(string message);
void Info(string message);
void Warning(string message);
}
}

View File

@ -0,0 +1,28 @@
using Bit.Core.Abstractions;
using System;
namespace Bit.Core.Services
{
public class ConsoleLogService : ILogService
{
public void Debug(string message)
{
Console.WriteLine("DEBUG: {0}", message);
}
public void Info(string message)
{
Console.WriteLine("INFO: {0}", message);
}
public void Warning(string message)
{
Console.WriteLine("WARNING: {0}", message);
}
public void Error(string message)
{
Console.WriteLine("ERROR: {0}", message);
}
}
}