Skip to content

Commit c87fd85

Browse files
committed
Switch from Serilog to Microsoft.Extensions.Logging (#43).
1 parent 52070bf commit c87fd85

24 files changed

+601
-449
lines changed

LSP.sln

Lines changed: 64 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
21
Microsoft Visual Studio Solution File, Format Version 12.00
32
# Visual Studio 15
4-
VisualStudioVersion = 15.0.26403.7
3+
VisualStudioVersion = 15.0.26730.16
54
MinimumVisualStudioVersion = 10.0.40219.1
65
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{D764E024-3D3F-4112-B932-2DB722A1BACC}"
76
EndProject
@@ -28,68 +27,108 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JsonRpc.Tests", "test\JsonR
2827
EndProject
2928
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lsp.Tests", "test\Lsp.Tests\Lsp.Tests.csproj", "{482B180B-FD5C-4705-BBE1-094C905F1E1F}"
3029
EndProject
31-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleServer", "sample\SampleServer\SampleServer.csproj", "{F2067F5F-FA4E-4990-B301-E7898FC4C45F}"
30+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleServer", "sample\SampleServer\SampleServer.csproj", "{F2067F5F-FA4E-4990-B301-E7898FC4C45F}"
3231
EndProject
3332
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sample", "sample", "{A316FCEC-81AD-45FB-93EE-C62CA09300DC}"
3433
EndProject
35-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client", "src\Client\Client.csproj", "{417E95B2-5AB9-49D5-B7CD-12255472E2E7}"
34+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Client", "src\Client\Client.csproj", "{417E95B2-5AB9-49D5-B7CD-12255472E2E7}"
3635
EndProject
37-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client.Tests", "test\Client.Tests\Client.Tests.csproj", "{97437BE1-2EC3-4F6B-AC75-C3E099040A07}"
36+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Client.Tests", "test\Client.Tests\Client.Tests.csproj", "{97437BE1-2EC3-4F6B-AC75-C3E099040A07}"
3837
EndProject
3938
Global
4039
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4140
Debug|Any CPU = Debug|Any CPU
42-
Release|Any CPU = Release|Any CPU
4341
Debug|x64 = Debug|x64
4442
Debug|x86 = Debug|x86
43+
Release|Any CPU = Release|Any CPU
4544
Release|x64 = Release|x64
4645
Release|x86 = Release|x86
4746
EndGlobalSection
4847
GlobalSection(ProjectConfigurationPlatforms) = postSolution
4948
{9AF43FA2-EF35-435E-B59E-724877E44DDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
5049
{9AF43FA2-EF35-435E-B59E-724877E44DDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
50+
{9AF43FA2-EF35-435E-B59E-724877E44DDA}.Debug|x64.ActiveCfg = Debug|Any CPU
51+
{9AF43FA2-EF35-435E-B59E-724877E44DDA}.Debug|x64.Build.0 = Debug|Any CPU
52+
{9AF43FA2-EF35-435E-B59E-724877E44DDA}.Debug|x86.ActiveCfg = Debug|Any CPU
53+
{9AF43FA2-EF35-435E-B59E-724877E44DDA}.Debug|x86.Build.0 = Debug|Any CPU
5154
{9AF43FA2-EF35-435E-B59E-724877E44DDA}.Release|Any CPU.ActiveCfg = Release|Any CPU
5255
{9AF43FA2-EF35-435E-B59E-724877E44DDA}.Release|Any CPU.Build.0 = Release|Any CPU
56+
{9AF43FA2-EF35-435E-B59E-724877E44DDA}.Release|x64.ActiveCfg = Release|Any CPU
57+
{9AF43FA2-EF35-435E-B59E-724877E44DDA}.Release|x64.Build.0 = Release|Any CPU
58+
{9AF43FA2-EF35-435E-B59E-724877E44DDA}.Release|x86.ActiveCfg = Release|Any CPU
59+
{9AF43FA2-EF35-435E-B59E-724877E44DDA}.Release|x86.Build.0 = Release|Any CPU
5360
{50EA648A-67D3-4127-9517-EC7C1426E2E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
5461
{50EA648A-67D3-4127-9517-EC7C1426E2E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
62+
{50EA648A-67D3-4127-9517-EC7C1426E2E7}.Debug|x64.ActiveCfg = Debug|Any CPU
63+
{50EA648A-67D3-4127-9517-EC7C1426E2E7}.Debug|x64.Build.0 = Debug|Any CPU
64+
{50EA648A-67D3-4127-9517-EC7C1426E2E7}.Debug|x86.ActiveCfg = Debug|Any CPU
65+
{50EA648A-67D3-4127-9517-EC7C1426E2E7}.Debug|x86.Build.0 = Debug|Any CPU
5566
{50EA648A-67D3-4127-9517-EC7C1426E2E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
5667
{50EA648A-67D3-4127-9517-EC7C1426E2E7}.Release|Any CPU.Build.0 = Release|Any CPU
68+
{50EA648A-67D3-4127-9517-EC7C1426E2E7}.Release|x64.ActiveCfg = Release|Any CPU
69+
{50EA648A-67D3-4127-9517-EC7C1426E2E7}.Release|x64.Build.0 = Release|Any CPU
70+
{50EA648A-67D3-4127-9517-EC7C1426E2E7}.Release|x86.ActiveCfg = Release|Any CPU
71+
{50EA648A-67D3-4127-9517-EC7C1426E2E7}.Release|x86.Build.0 = Release|Any CPU
5772
{35F9B883-36D0-4F3B-A191-9BBD05B798A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
5873
{35F9B883-36D0-4F3B-A191-9BBD05B798A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
74+
{35F9B883-36D0-4F3B-A191-9BBD05B798A7}.Debug|x64.ActiveCfg = Debug|Any CPU
75+
{35F9B883-36D0-4F3B-A191-9BBD05B798A7}.Debug|x64.Build.0 = Debug|Any CPU
76+
{35F9B883-36D0-4F3B-A191-9BBD05B798A7}.Debug|x86.ActiveCfg = Debug|Any CPU
77+
{35F9B883-36D0-4F3B-A191-9BBD05B798A7}.Debug|x86.Build.0 = Debug|Any CPU
5978
{35F9B883-36D0-4F3B-A191-9BBD05B798A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
6079
{35F9B883-36D0-4F3B-A191-9BBD05B798A7}.Release|Any CPU.Build.0 = Release|Any CPU
80+
{35F9B883-36D0-4F3B-A191-9BBD05B798A7}.Release|x64.ActiveCfg = Release|Any CPU
81+
{35F9B883-36D0-4F3B-A191-9BBD05B798A7}.Release|x64.Build.0 = Release|Any CPU
82+
{35F9B883-36D0-4F3B-A191-9BBD05B798A7}.Release|x86.ActiveCfg = Release|Any CPU
83+
{35F9B883-36D0-4F3B-A191-9BBD05B798A7}.Release|x86.Build.0 = Release|Any CPU
6184
{482B180B-FD5C-4705-BBE1-094C905F1E1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
6285
{482B180B-FD5C-4705-BBE1-094C905F1E1F}.Debug|Any CPU.Build.0 = Debug|Any CPU
86+
{482B180B-FD5C-4705-BBE1-094C905F1E1F}.Debug|x64.ActiveCfg = Debug|Any CPU
87+
{482B180B-FD5C-4705-BBE1-094C905F1E1F}.Debug|x64.Build.0 = Debug|Any CPU
88+
{482B180B-FD5C-4705-BBE1-094C905F1E1F}.Debug|x86.ActiveCfg = Debug|Any CPU
89+
{482B180B-FD5C-4705-BBE1-094C905F1E1F}.Debug|x86.Build.0 = Debug|Any CPU
6390
{482B180B-FD5C-4705-BBE1-094C905F1E1F}.Release|Any CPU.ActiveCfg = Release|Any CPU
6491
{482B180B-FD5C-4705-BBE1-094C905F1E1F}.Release|Any CPU.Build.0 = Release|Any CPU
92+
{482B180B-FD5C-4705-BBE1-094C905F1E1F}.Release|x64.ActiveCfg = Release|Any CPU
93+
{482B180B-FD5C-4705-BBE1-094C905F1E1F}.Release|x64.Build.0 = Release|Any CPU
94+
{482B180B-FD5C-4705-BBE1-094C905F1E1F}.Release|x86.ActiveCfg = Release|Any CPU
95+
{482B180B-FD5C-4705-BBE1-094C905F1E1F}.Release|x86.Build.0 = Release|Any CPU
6596
{F2067F5F-FA4E-4990-B301-E7898FC4C45F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
6697
{F2067F5F-FA4E-4990-B301-E7898FC4C45F}.Debug|Any CPU.Build.0 = Debug|Any CPU
98+
{F2067F5F-FA4E-4990-B301-E7898FC4C45F}.Debug|x64.ActiveCfg = Debug|Any CPU
99+
{F2067F5F-FA4E-4990-B301-E7898FC4C45F}.Debug|x64.Build.0 = Debug|Any CPU
100+
{F2067F5F-FA4E-4990-B301-E7898FC4C45F}.Debug|x86.ActiveCfg = Debug|Any CPU
101+
{F2067F5F-FA4E-4990-B301-E7898FC4C45F}.Debug|x86.Build.0 = Debug|Any CPU
67102
{F2067F5F-FA4E-4990-B301-E7898FC4C45F}.Release|Any CPU.ActiveCfg = Release|Any CPU
68103
{F2067F5F-FA4E-4990-B301-E7898FC4C45F}.Release|Any CPU.Build.0 = Release|Any CPU
104+
{F2067F5F-FA4E-4990-B301-E7898FC4C45F}.Release|x64.ActiveCfg = Release|Any CPU
105+
{F2067F5F-FA4E-4990-B301-E7898FC4C45F}.Release|x64.Build.0 = Release|Any CPU
106+
{F2067F5F-FA4E-4990-B301-E7898FC4C45F}.Release|x86.ActiveCfg = Release|Any CPU
107+
{F2067F5F-FA4E-4990-B301-E7898FC4C45F}.Release|x86.Build.0 = Release|Any CPU
69108
{417E95B2-5AB9-49D5-B7CD-12255472E2E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
70109
{417E95B2-5AB9-49D5-B7CD-12255472E2E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
71-
{417E95B2-5AB9-49D5-B7CD-12255472E2E7}.Debug|x64.ActiveCfg = Debug|x64
72-
{417E95B2-5AB9-49D5-B7CD-12255472E2E7}.Debug|x64.Build.0 = Debug|x64
73-
{417E95B2-5AB9-49D5-B7CD-12255472E2E7}.Debug|x86.ActiveCfg = Debug|x86
74-
{417E95B2-5AB9-49D5-B7CD-12255472E2E7}.Debug|x86.Build.0 = Debug|x86
110+
{417E95B2-5AB9-49D5-B7CD-12255472E2E7}.Debug|x64.ActiveCfg = Debug|Any CPU
111+
{417E95B2-5AB9-49D5-B7CD-12255472E2E7}.Debug|x64.Build.0 = Debug|Any CPU
112+
{417E95B2-5AB9-49D5-B7CD-12255472E2E7}.Debug|x86.ActiveCfg = Debug|Any CPU
113+
{417E95B2-5AB9-49D5-B7CD-12255472E2E7}.Debug|x86.Build.0 = Debug|Any CPU
75114
{417E95B2-5AB9-49D5-B7CD-12255472E2E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
76115
{417E95B2-5AB9-49D5-B7CD-12255472E2E7}.Release|Any CPU.Build.0 = Release|Any CPU
77-
{417E95B2-5AB9-49D5-B7CD-12255472E2E7}.Release|x64.ActiveCfg = Release|x64
78-
{417E95B2-5AB9-49D5-B7CD-12255472E2E7}.Release|x64.Build.0 = Release|x64
79-
{417E95B2-5AB9-49D5-B7CD-12255472E2E7}.Release|x86.ActiveCfg = Release|x86
80-
{417E95B2-5AB9-49D5-B7CD-12255472E2E7}.Release|x86.Build.0 = Release|x86
116+
{417E95B2-5AB9-49D5-B7CD-12255472E2E7}.Release|x64.ActiveCfg = Release|Any CPU
117+
{417E95B2-5AB9-49D5-B7CD-12255472E2E7}.Release|x64.Build.0 = Release|Any CPU
118+
{417E95B2-5AB9-49D5-B7CD-12255472E2E7}.Release|x86.ActiveCfg = Release|Any CPU
119+
{417E95B2-5AB9-49D5-B7CD-12255472E2E7}.Release|x86.Build.0 = Release|Any CPU
81120
{97437BE1-2EC3-4F6B-AC75-C3E099040A07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
82121
{97437BE1-2EC3-4F6B-AC75-C3E099040A07}.Debug|Any CPU.Build.0 = Debug|Any CPU
83-
{97437BE1-2EC3-4F6B-AC75-C3E099040A07}.Debug|x64.ActiveCfg = Debug|x64
84-
{97437BE1-2EC3-4F6B-AC75-C3E099040A07}.Debug|x64.Build.0 = Debug|x64
85-
{97437BE1-2EC3-4F6B-AC75-C3E099040A07}.Debug|x86.ActiveCfg = Debug|x86
86-
{97437BE1-2EC3-4F6B-AC75-C3E099040A07}.Debug|x86.Build.0 = Debug|x86
122+
{97437BE1-2EC3-4F6B-AC75-C3E099040A07}.Debug|x64.ActiveCfg = Debug|Any CPU
123+
{97437BE1-2EC3-4F6B-AC75-C3E099040A07}.Debug|x64.Build.0 = Debug|Any CPU
124+
{97437BE1-2EC3-4F6B-AC75-C3E099040A07}.Debug|x86.ActiveCfg = Debug|Any CPU
125+
{97437BE1-2EC3-4F6B-AC75-C3E099040A07}.Debug|x86.Build.0 = Debug|Any CPU
87126
{97437BE1-2EC3-4F6B-AC75-C3E099040A07}.Release|Any CPU.ActiveCfg = Release|Any CPU
88127
{97437BE1-2EC3-4F6B-AC75-C3E099040A07}.Release|Any CPU.Build.0 = Release|Any CPU
89-
{97437BE1-2EC3-4F6B-AC75-C3E099040A07}.Release|x64.ActiveCfg = Release|x64
90-
{97437BE1-2EC3-4F6B-AC75-C3E099040A07}.Release|x64.Build.0 = Release|x64
91-
{97437BE1-2EC3-4F6B-AC75-C3E099040A07}.Release|x86.ActiveCfg = Release|x86
92-
{97437BE1-2EC3-4F6B-AC75-C3E099040A07}.Release|x86.Build.0 = Release|x86
128+
{97437BE1-2EC3-4F6B-AC75-C3E099040A07}.Release|x64.ActiveCfg = Release|Any CPU
129+
{97437BE1-2EC3-4F6B-AC75-C3E099040A07}.Release|x64.Build.0 = Release|Any CPU
130+
{97437BE1-2EC3-4F6B-AC75-C3E099040A07}.Release|x86.ActiveCfg = Release|Any CPU
131+
{97437BE1-2EC3-4F6B-AC75-C3E099040A07}.Release|x86.Build.0 = Release|Any CPU
93132
EndGlobalSection
94133
GlobalSection(SolutionProperties) = preSolution
95134
HideSolutionNode = FALSE
@@ -103,4 +142,7 @@ Global
103142
{417E95B2-5AB9-49D5-B7CD-12255472E2E7} = {D764E024-3D3F-4112-B932-2DB722A1BACC}
104143
{97437BE1-2EC3-4F6B-AC75-C3E099040A07} = {2F323ED5-EBF8-45E1-B9D3-C014561B3DDA}
105144
EndGlobalSection
145+
GlobalSection(ExtensibilityGlobals) = postSolution
146+
SolutionGuid = {D38DD0EC-D095-4BCD-B8AF-2D788AF3B9AE}
147+
EndGlobalSection
106148
EndGlobal

src/Client/Client.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="1.0.2" />
1112
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
12-
<PackageReference Include="Serilog" Version="2.5.0" />
1313
<PackageReference Include="System.Reactive" Version="3.1.1" />
1414
<PackageReference Include="System.ValueTuple" Version="4.4.0" />
1515
</ItemGroup>

src/Client/Handlers/DynamicRegistrationHandler.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ public DynamicRegistrationHandler()
3232
/// </summary>
3333
public string Method => "client/registerCapability";
3434

35-
/// <summary>
36-
/// The kind of handler.
37-
/// </summary>
38-
public HandlerKind Kind => HandlerKind.Request;
39-
4035
/// <summary>
4136
/// Invoke the handler.
4237
/// </summary>

src/Client/Handlers/JsonRpcEmptyNotificationHandler.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ public JsonRpcEmptyNotificationHandler(string method, INotificationHandler handl
3333
/// </summary>
3434
public INotificationHandler Handler { get; }
3535

36-
/// <summary>
37-
/// The kind of handler.
38-
/// </summary>
39-
public override HandlerKind Kind => HandlerKind.EmptyNotification;
40-
4136
/// <summary>
4237
/// Invoke the handler.
4338
/// </summary>

src/Client/Handlers/JsonRpcHandler.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,5 @@ protected JsonRpcHandler(string method)
2727
/// The name of the method handled by the handler.
2828
/// </summary>
2929
public string Method { get; }
30-
31-
/// <summary>
32-
/// The kind of handler.
33-
/// </summary>
34-
public abstract HandlerKind Kind { get; }
3530
}
3631
}

src/Client/Handlers/JsonRpcNotificationHandler.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@ public JsonRpcNotificationHandler(string method, INotificationHandler<TNotificat
3737
/// </summary>
3838
public INotificationHandler<TNotification> Handler { get; }
3939

40-
/// <summary>
41-
/// The kind of handler.
42-
/// </summary>
43-
public override HandlerKind Kind => HandlerKind.Notification;
44-
4540
/// <summary>
4641
/// Invoke the handler.
4742
/// </summary>

src/Client/LanguageClient.cs

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Newtonsoft.Json.Linq;
2+
using Microsoft.Extensions.Logging;
23
using OmniSharp.Extensions.LanguageServer.Capabilities.Client;
34
using OmniSharp.Extensions.LanguageServer.Capabilities.Server;
45
using OmniSharp.Extensions.LanguageServer.Models;
@@ -8,7 +9,6 @@
89
using OmniSharp.Extensions.LanguageServerProtocol.Client.Protocol;
910
using OmniSharp.Extensions.LanguageServerProtocol.Client.Logging;
1011
using OmniSharp.Extensions.LanguageServerProtocol.Client.Clients;
11-
using Serilog;
1212
using System;
1313
using System.Diagnostics;
1414
using System.Threading;
@@ -56,28 +56,28 @@ public sealed class LanguageClient
5656
/// <summary>
5757
/// Create a new <see cref="LanguageClient"/>.
5858
/// </summary>
59-
/// <param name="logger">
60-
/// The logger to use.
59+
/// <param name="loggerFactory">
60+
/// The factory for loggers used by the client and its components.
6161
/// </param>
6262
/// <param name="serverStartInfo">
6363
/// A <see cref="ProcessStartInfo"/> describing how to start the server process.
6464
/// </param>
65-
public LanguageClient(ILogger logger, ProcessStartInfo serverStartInfo)
66-
: this(logger, new StdioServerProcess(logger, serverStartInfo))
65+
public LanguageClient(ILoggerFactory loggerFactory, ProcessStartInfo serverStartInfo)
66+
: this(loggerFactory, new StdioServerProcess(loggerFactory, serverStartInfo))
6767
{
6868
}
6969

7070
/// <summary>
7171
/// Create a new <see cref="LanguageClient"/>.
7272
/// </summary>
73-
/// <param name="logger">
74-
/// The application logger.
73+
/// <param name="loggerFactory">
74+
/// The factory for loggers used by the client and its components.
7575
/// </param>
7676
/// <param name="process">
7777
/// A <see cref="ServerProcess"/> used to start or connect to the server process.
7878
/// </param>
79-
public LanguageClient(ILogger logger, ServerProcess process)
80-
: this(logger)
79+
public LanguageClient(ILoggerFactory loggerFactory, ServerProcess process)
80+
: this(loggerFactory)
8181
{
8282
if (process == null)
8383
throw new ArgumentNullException(nameof(process));
@@ -89,15 +89,16 @@ public LanguageClient(ILogger logger, ServerProcess process)
8989
/// <summary>
9090
/// Create a new <see cref="LanguageClient"/>.
9191
/// </summary>
92-
/// <param name="logger">
92+
/// <param name="loggerFactory">
9393
/// The logger to use.
9494
/// </param>
95-
LanguageClient(ILogger logger)
95+
LanguageClient(ILoggerFactory loggerFactory)
9696
{
97-
if (logger == null)
98-
throw new ArgumentNullException(nameof(logger));
97+
if (loggerFactory == null)
98+
throw new ArgumentNullException(nameof(loggerFactory));
9999

100-
Log = logger.ForSourceContext<LanguageClient>();
100+
LoggerFactory = loggerFactory;
101+
Log = LoggerFactory.CreateLogger<LanguageClient>();
101102
Workspace = new WorkspaceClient(this);
102103
Window = new WindowClient(this);
103104
TextDocument = new TextDocumentClient(this);
@@ -117,6 +118,11 @@ public void Dispose()
117118
serverProcess?.Dispose();
118119
}
119120

121+
/// <summary>
122+
/// The factory for loggers used by the client and its components.
123+
/// </summary>
124+
ILoggerFactory LoggerFactory { get; }
125+
120126
/// <summary>
121127
/// The client's logger.
122128
/// </summary>
@@ -242,21 +248,21 @@ public Task HasShutdown
242248
InitializationOptions = initializationOptions
243249
};
244250

245-
Log.Verbose("Sending 'initialize' message to language server...");
251+
Log.LogDebug("Sending 'initialize' message to language server...");
246252

247253
InitializeResult result = await SendRequest<InitializeResult>("initialize", initializeParams, cancellationToken).ConfigureAwait(false);
248254
if (result == null)
249255
throw new LspException("Server replied to 'initialize' request with a null response.");
250256

251257
_dynamicRegistrationHandler.ServerCapabilities = result.Capabilities;
252258

253-
Log.Verbose("Sent 'initialize' message to language server.");
259+
Log.LogDebug("Sent 'initialize' message to language server.");
254260

255-
Log.Verbose("Sending 'initialized' notification to language server...");
261+
Log.LogDebug("Sending 'initialized' notification to language server...");
256262

257263
SendNotification("initialized");
258264

259-
Log.Verbose("Sent 'initialized' notification to language server.");
265+
Log.LogDebug("Sent 'initialized' notification to language server.");
260266

261267
IsInitialized = true;
262268
_readyCompletion.TrySetResult(null);
@@ -410,21 +416,21 @@ async Task Start()
410416

411417
if (!_process.IsRunning)
412418
{
413-
Log.Verbose("Starting language server...");
419+
Log.LogDebug("Starting language server...");
414420

415421
await _process.Start();
416422

417-
Log.Verbose("Language server is running.");
423+
Log.LogDebug("Language server is running.");
418424
}
419425

420-
Log.Verbose("Opening connection to language server...");
426+
Log.LogDebug("Opening connection to language server...");
421427

422428
if (_connection == null)
423-
_connection = new LspConnection(Log, input: _process.OutputStream, output: _process.InputStream);
429+
_connection = new LspConnection(LoggerFactory, input: _process.OutputStream, output: _process.InputStream);
424430

425431
_connection.Connect(_dispatcher);
426432

427-
Log.Verbose("Connection to language server is open.");
433+
Log.LogDebug("Connection to language server is open.");
428434
}
429435

430436
/// <summary>
@@ -438,7 +444,7 @@ async Task Start()
438444
/// </param>
439445
async void ServerProcess_Exit(object sender, EventArgs args)
440446
{
441-
Log.Verbose("Server process has exited; language client is shutting down...");
447+
Log.LogDebug("Server process has exited; language client is shutting down...");
442448

443449
LspConnection connection = Interlocked.Exchange(ref _connection, null);
444450
if (connection != null)
@@ -452,7 +458,7 @@ async void ServerProcess_Exit(object sender, EventArgs args)
452458

453459
await Shutdown();
454460

455-
Log.Verbose("Language client shutdown complete.");
461+
Log.LogDebug("Language client shutdown complete.");
456462
}
457463
}
458464
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System;
2+
using Microsoft.Extensions.Logging;
3+
4+
namespace OmniSharp.Extensions.LanguageServerProtocol.Client.Logging
5+
{
6+
/// <summary>
7+
/// Extension methods for <see cref="ILogger"/>.
8+
/// </summary>
9+
public static class LoggerExtensions
10+
{
11+
/// <summary>
12+
/// <see cref="EventId"/> representing a generic error event.
13+
/// </summary>
14+
public static EventId GenericErrorEventId = new EventId(500);
15+
16+
/// <summary>
17+
/// Log an error.
18+
/// </summary>
19+
/// <param name="logger">
20+
/// The <see cref="ILogger"/>.
21+
/// </param>
22+
/// <param name="exception">
23+
/// The exception (if any) associated with the error.
24+
/// </param>
25+
/// <param name="message">
26+
/// The log message.
27+
/// </param>
28+
/// <param name="args">
29+
/// The message format arguments (if any).
30+
/// </param>
31+
public static void LogError(this ILogger logger, Exception exception, string message, params object[] args)
32+
{
33+
if (logger == null)
34+
throw new ArgumentNullException(nameof(logger));
35+
36+
logger.LogError(GenericErrorEventId, exception, message, args);
37+
}
38+
}
39+
}

0 commit comments

Comments
 (0)