Skip to content

Commit

Permalink
change sentry to microsoft mobile center for log reports
Browse files Browse the repository at this point in the history
  • Loading branch information
theweavr committed Dec 21, 2017
1 parent 89fd4e0 commit 8aa504d
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 22 deletions.
16 changes: 8 additions & 8 deletions BreadPlayer.Common/BLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ public static ILogger Logger
}

private static ILogger _logger;
static ISentryMessageSender SentryMessageSender;
public static void InitLogger(string path, ISentryMessageSender sentryMessageSender)
static ILogReportSender LogReportSender;
public static void InitLogger(string path, ILogReportSender logReportSender)
{
SentryMessageSender = sentryMessageSender;
LogReportSender = logReportSender;
const string fileOutputTemplate = "{Timestamp:yyyy-MM-dd HH:mm:ss.fff} [{Level}] {Message}{NewLine}{Exception}";

Log.Logger = new LoggerConfiguration()
Expand All @@ -23,19 +23,19 @@ public static void InitLogger(string path, ISentryMessageSender sentryMessageSen
.CreateLogger();
Logger = Log.Logger;
I("Logger initialized.");
SentryMessageSender.InitSentry();
LogReportSender.Init();
I("Raven initialized.");
}

public static async void E(string message, Exception exception, params object[] propertyValues)
public static void E(string message, Exception exception, params object[] propertyValues)
{
Logger?.Error(exception, message, propertyValues);
await SentryMessageSender.SendMessageAsync(message, exception, "Error").ConfigureAwait(false);
//await LogReportSender.SendReportAsync(message, exception, "Error").ConfigureAwait(false);
}
public static async void F(string message, Exception exception, params object[] propertyValues)
public static void F(string message, Exception exception, params object[] propertyValues)
{
Logger?.Fatal(exception, message, propertyValues);
await SentryMessageSender.SendMessageAsync(message, exception, "Fatal").ConfigureAwait(false);
//await LogReportSender.SendReportAsync(message, exception, "Fatal").ConfigureAwait(false);
}
public static void I(string message, params object[] propertyValues)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

namespace BreadPlayer.Core
{
public interface ISentryMessageSender
public interface ILogReportSender
{
Task SendMessageAsync(string message, Exception ex, string errorLevel);
void InitSentry();
Task SendReportAsync(string message, Exception ex, string errorLevel);
void Init();
}
}
3 changes: 1 addition & 2 deletions BreadPlayer.Views.UWP/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ You should have received a copy of the GNU General Public License
using BreadPlayer.Services;
using BreadPlayer.Themes;
using Microsoft.Services.Store.Engagement;
using SharpRaven;
using System;
using System.Collections.Generic;
using System.Diagnostics;
Expand Down Expand Up @@ -63,7 +62,7 @@ private async void InitializeEverything()
if ((await StorageLibrary.GetLibraryAsync(KnownLibraryId.Music))?.SaveFolder != null)
{
var logPath = System.IO.Path.Combine((await StorageLibrary.GetLibraryAsync(KnownLibraryId.Music))?.SaveFolder?.Path, ".breadplayerLogs", "BreadPlayer.log");
BLogger.InitLogger(logPath, new SentryAPI.SentryMessageSender());
BLogger.InitLogger(logPath, new Helpers.LogReportSender());
CoreApplication.EnablePrelaunch(true);
Suspending += OnSuspending;
EnteredBackground += App_EnteredBackground;
Expand Down
19 changes: 11 additions & 8 deletions BreadPlayer.Views.UWP/BreadPlayer.Views.UWP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<AssemblyName>BreadPlayer</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion>10.0.15063.0</TargetPlatformVersion>
<TargetPlatformVersion>10.0.16299.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.14393.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
Expand Down Expand Up @@ -213,6 +213,7 @@
<Compile Include="Common\DirectoryWalker.cs" />
<Compile Include="Common\NotificationManager.cs" />
<Compile Include="Helpers\FmodFileSystem.cs" />
<Compile Include="Helpers\LogReportSender.cs" />
<Compile Include="Helpers\SettingsHelper.cs" />
<Compile Include="Converters\BoolToSelectionModeConverter.cs" />
<Compile Include="Converters\BrushToThemeConverter.cs" />
Expand Down Expand Up @@ -265,7 +266,6 @@
<Compile Include="PlaylistBus\M3U.cs" />
<Compile Include="Helpers\PlaylistHelper.cs" />
<Compile Include="PlaylistBus\PLS.cs" />
<Compile Include="SentryAPI\SentryMessageSender.cs" />
<Compile Include="Services\MTPDeviceService.cs" />
<Compile Include="Services\NavigationService.cs" />
<Compile Include="Services\StorageLibraryService.cs" />
Expand Down Expand Up @@ -569,11 +569,11 @@
<SDKReference Include="Microsoft.VCLibs, Version=14.0">
<Name>Visual C++ 2015 Runtime for Universal Windows Platform Apps</Name>
</SDKReference>
<SDKReference Include="WindowsDesktop, Version=10.0.15063.0">
<SDKReference Include="WindowsDesktop, Version=10.0.16299.0">
<Name>Windows Desktop Extensions for the UWP</Name>
</SDKReference>
<SDKReference Include="WindowsMobile, Version=10.0.15063.0">
<Name>Windows Mobile Extensions for the UWP %28WindowsMobile, Version=10.0.15063.0%29</Name>
<SDKReference Include="WindowsMobile, Version=10.0.16299.0">
<Name>Windows Mobile Extensions for the UWP</Name>
</SDKReference>
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -625,6 +625,12 @@
<PackageReference Include="Microsoft.Advertising.XAML">
<Version>10.1705.16001</Version>
</PackageReference>
<PackageReference Include="Microsoft.AppCenter.Analytics">
<Version>1.1.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.AppCenter.Crashes">
<Version>1.1.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>6.0.1</Version>
</PackageReference>
Expand Down Expand Up @@ -652,9 +658,6 @@
<PackageReference Include="SharpCifs.Std">
<Version>0.2.11</Version>
</PackageReference>
<PackageReference Include="SharpRavenPCL">
<Version>1.0.2</Version>
</PackageReference>
<PackageReference Include="System.ValueTuple">
<Version>4.4.0</Version>
</PackageReference>
Expand Down
27 changes: 27 additions & 0 deletions BreadPlayer.Views.UWP/Helpers/LogReportSender.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using BreadPlayer.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AppCenter;
using Microsoft.AppCenter.Analytics;
using Microsoft.AppCenter.Crashes;

namespace BreadPlayer.Helpers
{
public class LogReportSender : ILogReportSender
{
public async void Init()
{
AppCenter.Start("3a3c519a-67b0-487d-bb6b-f2a94c2e2303", typeof(Analytics), typeof(Crashes));
await AppCenter.SetEnabledAsync(true);
}

public Task SendReportAsync(string message, Exception ex, string errorLevel)
{
return null;
//throw new NotImplementedException();
}
}
}
2 changes: 1 addition & 1 deletion BreadPlayer.Views.UWP/SentryAPI/SentryMessageSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace BreadPlayer.SentryAPI
{
public class SentryMessageSender : ISentryMessageSender
public class SentryMessageSender : ILogReportSender
{
private RavenClient ravenClient;
public void InitSentry()
Expand Down

0 comments on commit 8aa504d

Please sign in to comment.