Skip to content

Commit 4ed07d3

Browse files
committed
update libsignal, implement console logger
1 parent 9d2d6a3 commit 4ed07d3

File tree

3 files changed

+54
-1
lines changed

3 files changed

+54
-1
lines changed

Signal-Windows/App.xaml.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using libsignalservice.push;
2+
using libsignalservice;
23
using Signal_Windows.Models;
34
using Signal_Windows.Storage;
45
using Signal_Windows.ViewModels;
@@ -14,6 +15,8 @@
1415
using Windows.UI.Xaml.Navigation;
1516
using Microsoft.QueryStringDotNET;
1617
using Windows.UI.Notifications;
18+
using Microsoft.Extensions.Logging;
19+
using Windows.Foundation.Diagnostics;
1720

1821
namespace Signal_Windows
1922
{
@@ -39,6 +42,7 @@ sealed partial class App : Application
3942
/// </summary>
4043
public App()
4144
{
45+
LibsignalLogging.LoggerFactory.AddProvider(new SignalLoggerProvider());
4246
this.InitializeComponent();
4347
this.Suspending += OnSuspending;
4448
this.Resuming += App_Resuming;

Signal-Windows/Signal-Windows.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,10 @@
196196
<Compile Include="Models\SignalSignedPreKey.cs" />
197197
<Compile Include="Models\SignalStore.cs" />
198198
<Compile Include="Models\SignalConversation.cs" />
199+
<Compile Include="SignalLogging.cs" />
199200
<Compile Include="Signal\IncomingMessages.cs" />
200201
<Compile Include="Signal\OutgoingMessages.cs" />
202+
<Compile Include="Storage\SignalLogging.cs" />
201203
<Compile Include="Storage\Store.cs" />
202204
<Compile Include="Utils.cs" />
203205
<Compile Include="ViewModels\AddContactPageViewModel.cs" />
@@ -311,7 +313,7 @@
311313
</ItemGroup>
312314
<ItemGroup>
313315
<PackageReference Include="libsignal-service-dotnet">
314-
<Version>2.5.10.5</Version>
316+
<Version>2.5.10.6</Version>
315317
</PackageReference>
316318
<PackageReference Include="Microsoft.EntityFrameworkCore">
317319
<Version>1.1.2</Version>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using Microsoft.Extensions.Logging;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Diagnostics;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
9+
namespace Signal_Windows.Storage
10+
{
11+
class SignalConsoleLogger : ILogger
12+
{
13+
private readonly string ClassName;
14+
public SignalConsoleLogger(string categoryName)
15+
{
16+
ClassName = categoryName;
17+
}
18+
19+
public IDisposable BeginScope<TState>(TState state)
20+
{
21+
throw new NotImplementedException();
22+
}
23+
24+
public bool IsEnabled(LogLevel logLevel)
25+
{
26+
return true;
27+
}
28+
29+
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
30+
{
31+
Debug.WriteLine(string.Format("[{0}] [{1}] ", logLevel, ClassName) + formatter(state, exception));
32+
}
33+
}
34+
35+
class SignalLoggerProvider : ILoggerProvider
36+
{
37+
public ILogger CreateLogger(string categoryName)
38+
{
39+
return new SignalConsoleLogger(categoryName);
40+
}
41+
42+
public void Dispose()
43+
{
44+
Debug.WriteLine("disposing SignalLoggerProvider");
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)