Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit fd89bf3

Browse files
authored
Merge branch 'master' into fixes/install-cmd
2 parents 73310ec + df50338 commit fd89bf3

File tree

93 files changed

+668
-507
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+668
-507
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<ProjectConfiguration>
2+
<Settings>
3+
<PreviouslyBuiltSuccessfully>True</PreviouslyBuiltSuccessfully>
4+
</Settings>
5+
</ProjectConfiguration>

GitHubVS.sln

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitHub.InlineReviews", "src
104104
EndProject
105105
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitHub.InlineReviews.UnitTests", "test\GitHub.InlineReviews.UnitTests\GitHub.InlineReviews.UnitTests.csproj", "{17EB676B-BB91-48B5-AA59-C67695C647C2}"
106106
EndProject
107+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitHub.Logging", "src\GitHub.Logging\GitHub.Logging.csproj", "{8D73575A-A89F-47CC-B153-B47DD06837F0}"
108+
EndProject
107109
Global
108110
GlobalSection(SolutionConfigurationPlatforms) = preSolution
109111
Debug|Any CPU = Debug|Any CPU
@@ -403,6 +405,16 @@ Global
403405
{17EB676B-BB91-48B5-AA59-C67695C647C2}.Release|Any CPU.Build.0 = Release|Any CPU
404406
{17EB676B-BB91-48B5-AA59-C67695C647C2}.ReleaseWithoutVsix|Any CPU.ActiveCfg = Release|Any CPU
405407
{17EB676B-BB91-48B5-AA59-C67695C647C2}.ReleaseWithoutVsix|Any CPU.Build.0 = Release|Any CPU
408+
{8D73575A-A89F-47CC-B153-B47DD06837F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
409+
{8D73575A-A89F-47CC-B153-B47DD06837F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
410+
{8D73575A-A89F-47CC-B153-B47DD06837F0}.DebugCodeAnalysis|Any CPU.ActiveCfg = DebugCodeAnalysis|Any CPU
411+
{8D73575A-A89F-47CC-B153-B47DD06837F0}.DebugCodeAnalysis|Any CPU.Build.0 = DebugCodeAnalysis|Any CPU
412+
{8D73575A-A89F-47CC-B153-B47DD06837F0}.DebugWithoutVsix|Any CPU.ActiveCfg = Debug|Any CPU
413+
{8D73575A-A89F-47CC-B153-B47DD06837F0}.DebugWithoutVsix|Any CPU.Build.0 = Debug|Any CPU
414+
{8D73575A-A89F-47CC-B153-B47DD06837F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
415+
{8D73575A-A89F-47CC-B153-B47DD06837F0}.Release|Any CPU.Build.0 = Release|Any CPU
416+
{8D73575A-A89F-47CC-B153-B47DD06837F0}.ReleaseWithoutVsix|Any CPU.ActiveCfg = Release|Any CPU
417+
{8D73575A-A89F-47CC-B153-B47DD06837F0}.ReleaseWithoutVsix|Any CPU.Build.0 = Release|Any CPU
406418
EndGlobalSection
407419
GlobalSection(SolutionProperties) = preSolution
408420
HideSolutionNode = FALSE

src/GitHub.Api/GitHub.Api.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@
9494
<Project>{6afe2e2d-6db0-4430-a2ea-f5f5388d2f78}</Project>
9595
<Name>GitHub.Extensions</Name>
9696
</ProjectReference>
97+
<ProjectReference Include="..\GitHub.Logging\GitHub.Logging.csproj">
98+
<Project>{8d73575a-a89f-47cc-b153-b47dd06837f0}</Project>
99+
<Name>GitHub.Logging</Name>
100+
</ProjectReference>
97101
</ItemGroup>
98102
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
99103
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

src/GitHub.App/Api/ApiClient.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using System.Security.Cryptography;
99
using System.Text;
1010
using GitHub.Primitives;
11-
using NLog;
1211
using Octokit;
1312
using Octokit.Reactive;
1413
using ReactiveUI;
@@ -18,14 +17,16 @@
1817
using System.Collections.Generic;
1918
using GitHub.Models;
2019
using GitHub.Extensions;
20+
using GitHub.Logging;
21+
using Serilog;
2122

2223
namespace GitHub.Api
2324
{
2425
public partial class ApiClient : IApiClient
2526
{
2627
const string ScopesHeader = "X-OAuth-Scopes";
2728
const string ProductName = Info.ApplicationInfo.ApplicationDescription;
28-
static readonly Logger log = LogManager.GetCurrentClassLogger();
29+
static readonly ILogger log = LogManager.ForContext<ApiClient>();
2930

3031
readonly IObservableGitHubClient gitHubClient;
3132
// There are two sets of authorization scopes, old and new:
@@ -187,7 +188,7 @@ static string GetSha256Hash(string input)
187188
}
188189
catch (Exception e)
189190
{
190-
log.Error("IMPOSSIBLE! Generating Sha256 hash caused an exception.", e);
191+
log.Error(e, "IMPOSSIBLE! Generating Sha256 hash caused an exception");
191192
return null;
192193
}
193194
}
@@ -205,14 +206,14 @@ static string GetMachineNameSafe()
205206
}
206207
catch (Exception e)
207208
{
208-
log.Info("Failed to retrieve host name using `DNS.GetHostName`.", e);
209+
log.Information(e, "Failed to retrieve host name using `DNS.GetHostName`");
209210
try
210211
{
211212
return Environment.MachineName;
212213
}
213214
catch (Exception ex)
214215
{
215-
log.Info("Failed to retrieve host name using `Environment.MachineName`.", ex);
216+
log.Warning(ex, "Failed to retrieve host name using `Environment.MachineName`");
216217
return "(unknown)";
217218
}
218219
}
@@ -233,7 +234,7 @@ static string GetMachineIdentifier()
233234
}
234235
catch (Exception e)
235236
{
236-
log.Info("Could not retrieve MAC address. Fallback to using machine name.", e);
237+
log.Warning(e, "Could not retrieve MAC address. Fallback to using machine name");
237238
return GetMachineNameSafe();
238239
}
239240
}

src/GitHub.App/Caches/ImageCache.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,18 @@
1111
using GitHub.Extensions;
1212
using GitHub.Extensions.Reactive;
1313
using GitHub.Factories;
14+
using GitHub.Logging;
1415
using GitHub.Services;
1516
using Rothko;
17+
using Serilog;
1618

1719
namespace GitHub.Caches
1820
{
1921
[Export(typeof(IImageCache))]
2022
[PartCreationPolicy(CreationPolicy.Shared)]
2123
public sealed class ImageCache : IImageCache
2224
{
23-
static readonly NLog.Logger log = NLog.LogManager.GetCurrentClassLogger();
25+
static readonly ILogger log = LogManager.ForContext<ImageCache>();
2426

2527
public const string ImageCacheFileName = "images.cache.db";
2628
readonly IObservable<IBlobCache> cacheFactory;
@@ -159,7 +161,7 @@ static IObservable<Unit> VacuumIfNecessary(IBlobCache blobCache, bool force = fa
159161
.SelectMany(Observable.Defer(() => blobCache.Insert(key, new byte[] { 1 })))
160162
.Catch<Unit, Exception>(ex =>
161163
{
162-
log.Error("Could not vacuum image cache", ex);
164+
log.Error(ex, "Could not vacuum image cache");
163165
return Observable.Return(Unit.Default);
164166
})
165167
.AsCompletion();

src/GitHub.App/Caches/LoginCache.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@
55
using System.Reactive.Linq;
66
using Akavache;
77
using GitHub.Extensions;
8+
using GitHub.Logging;
89
using GitHub.Primitives;
9-
using NLog;
10+
using Serilog;
11+
using Serilog.Core;
1012

1113
namespace GitHub.Caches
1214
{
1315
[Export(typeof(ILoginCache))]
1416
[PartCreationPolicy(CreationPolicy.Shared)]
1517
public sealed class LoginCache : ILoginCache
1618
{
17-
static readonly Logger log = LogManager.GetCurrentClassLogger();
19+
static readonly ILogger log = LogManager.ForContext<LoginCache>();
1820
readonly ISharedCache cache;
1921

2022
static readonly LoginInfo empty = new LoginInfo("", "");
@@ -46,14 +48,13 @@ public IObservable<Unit> SaveLogin(string user, string password, HostAddress hos
4648

4749
public IObservable<Unit> EraseLogin(HostAddress hostAddress)
4850
{
49-
log.Info(CultureInfo.CurrentCulture, "Erasing the git credential cache for host '{0}'",
50-
hostAddress.CredentialCacheKeyHost);
51+
log.Information("Erasing the git credential cache for host {CredentialCacheKeyHost}", hostAddress.CredentialCacheKeyHost);
5152
return cache.Secure.EraseLogin(hostAddress.CredentialCacheKeyHost);
5253
}
5354

5455
public IObservable<Unit> Flush()
5556
{
56-
log.Info("Flushing the login cache");
57+
log.Verbose("Flushing the login cache");
5758
return cache.Secure.Flush();
5859
}
5960

src/GitHub.App/Caches/SharedCache.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
using System.Reactive;
55
using System.Reactive.Linq;
66
using Akavache;
7-
using NLog;
7+
using GitHub.Logging;
8+
using Serilog;
89

910
namespace GitHub.Caches
1011
{
@@ -16,7 +17,7 @@ namespace GitHub.Caches
1617
public class SharedCache : ISharedCache
1718
{
1819
const string enterpriseHostApiBaseUriCacheKey = "enterprise-host-api-base-uri";
19-
static readonly Logger log = LogManager.GetCurrentClassLogger();
20+
static readonly ILogger log = LogManager.ForContext<SharedCache>();
2021

2122
static SharedCache()
2223
{
@@ -26,7 +27,7 @@ static SharedCache()
2627
}
2728
catch (Exception e)
2829
{
29-
log.Error("Error while running the static inializer for SharedCache", e);
30+
log.Error(e, "Error while running the static inializer for SharedCache");
3031
}
3132
}
3233

@@ -45,7 +46,7 @@ protected SharedCache(IBlobCache userAccountCache, IBlobCache localMachineCache,
4546
}
4647
catch (Exception e)
4748
{
48-
log.Error("Failed to set up secure cache.", e);
49+
log.Error(e, "Failed to set up secure cache");
4950
secureCache = new InMemoryBlobCache();
5051
}
5152
}
@@ -104,7 +105,7 @@ static IBlobCache GetBlobCacheWithFallback(Func<IBlobCache> blobCacheFunc, strin
104105
}
105106
catch (Exception e)
106107
{
107-
log.Error(string.Format(CultureInfo.InvariantCulture, "Failed to set the {0} cache.", cacheName), e);
108+
log.Error(e, "Failed to set the {CacheName} cache", cacheName);
108109
return new InMemoryBlobCache();
109110
}
110111
}

src/GitHub.App/Controllers/UIController.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using System.Reactive.Linq;
1616
using System.Reactive.Subjects;
1717
using System.Windows;
18+
using GitHub.Logging;
1819

1920
namespace GitHub.Controllers
2021
{
@@ -166,12 +167,12 @@ public UIController(IGitHubServiceProvider gitHubServiceProvider,
166167
var waitDispatcher = RxApp.MainThreadScheduler as WaitForDispatcherScheduler;
167168
if (waitDispatcher != null)
168169
{
169-
Debug.Assert(DispatcherScheduler.Current.Dispatcher == Application.Current.Dispatcher,
170+
Log.Assert(DispatcherScheduler.Current.Dispatcher == Application.Current.Dispatcher,
170171
"DispatcherScheduler is set correctly");
171172
}
172173
else
173174
{
174-
Debug.Assert(((DispatcherScheduler)RxApp.MainThreadScheduler).Dispatcher == Application.Current.Dispatcher,
175+
Log.Assert(((DispatcherScheduler)RxApp.MainThreadScheduler).Dispatcher == Application.Current.Dispatcher,
175176
"The MainThreadScheduler is using the wrong dispatcher");
176177
}
177178
}
@@ -217,7 +218,7 @@ public void Start()
217218
if (selectedFlow != UIControllerFlow.Authentication)
218219
gitHubServiceProvider.AddService(this, connection);
219220
else // sanity check: it makes zero sense to pass a connection in when calling the auth flow
220-
Debug.Assert(false, "Calling the auth flow with a connection makes no sense!");
221+
Log.Assert(false, "Calling the auth flow with a connection makes no sense!");
221222

222223
connection.Login()
223224
.ObserveOn(RxApp.MainThreadScheduler)

src/GitHub.App/Factories/ApiClientFactory.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
using Octokit;
88
using Octokit.Reactive;
99
using ApiClient = GitHub.Api.ApiClient;
10-
using GitHub.Infrastructure;
10+
using GitHub.Logging;
1111
using System.Threading.Tasks;
1212
using ILoginCache = GitHub.Caches.ILoginCache;
1313

@@ -20,11 +20,10 @@ public class ApiClientFactory : IApiClientFactory
2020
readonly ProductHeaderValue productHeader;
2121

2222
[ImportingConstructor]
23-
public ApiClientFactory(ILoginCache loginCache, IProgram program, ILoggingConfiguration config)
23+
public ApiClientFactory(ILoginCache loginCache, IProgram program)
2424
{
2525
LoginCache = loginCache;
2626
productHeader = program.ProductHeader;
27-
config.Configure();
2827
}
2928

3029
public Task<IGitHubClient> CreateGitHubClient(HostAddress hostAddress)

src/GitHub.App/Factories/SqlitePersistentBlobCacheFactory.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
using Akavache;
22
using Akavache.Sqlite3;
3-
using NLog;
43
using System;
54
using System.Collections.Generic;
65
using System.ComponentModel.Composition;
76
using System.Reactive.Linq;
87
using System.Threading.Tasks;
98
using GitHub.Extensions;
9+
using GitHub.Logging;
10+
using Serilog;
1011

1112
namespace GitHub.Factories
1213
{
1314
[Export(typeof(IBlobCacheFactory))]
1415
[PartCreationPolicy(CreationPolicy.Shared)]
1516
public class SqlitePersistentBlobCacheFactory : IBlobCacheFactory
1617
{
17-
static readonly Logger log = LogManager.GetCurrentClassLogger();
18+
static readonly ILogger log = LogManager.ForContext<SqlitePersistentBlobCacheFactory>();
1819
Dictionary<string, IBlobCache> cache = new Dictionary<string, IBlobCache>();
1920

2021
public IBlobCache CreateBlobCache(string path)
@@ -31,7 +32,7 @@ public IBlobCache CreateBlobCache(string path)
3132
}
3233
catch(Exception ex)
3334
{
34-
log.Error("Error while creating SQLitePersistentBlobCache for {0}. {1}", path, ex);
35+
log.Error(ex, "Error while creating SQLitePersistentBlobCache for {Path}", path);
3536
return new InMemoryBlobCache();
3637
}
3738
}

0 commit comments

Comments
 (0)