16
16
using OmniSharp . LanguageServerProtocol . Eventing ;
17
17
using OmniSharp . LanguageServerProtocol . Handlers ;
18
18
using OmniSharp . Mef ;
19
- using OmniSharp . Models . Diagnostics ;
20
19
using OmniSharp . Options ;
21
20
using OmniSharp . Roslyn ;
22
21
using OmniSharp . Services ;
@@ -28,7 +27,6 @@ internal class LanguageServerHost : IDisposable
28
27
{
29
28
private readonly LanguageServerOptions _options ;
30
29
private IServiceCollection _services ;
31
- private readonly LoggerFactory _loggerFactory ;
32
30
private readonly CommandLineApplication _application ;
33
31
private readonly CancellationTokenSource _cancellationTokenSource ;
34
32
private CompositionHost _compositionHost ;
@@ -44,24 +42,24 @@ public LanguageServerHost(
44
42
CommandLineApplication application ,
45
43
CancellationTokenSource cancellationTokenSource )
46
44
{
47
- _loggerFactory = new LoggerFactory ( ) ;
48
- _logger = _loggerFactory . CreateLogger < LanguageServerHost > ( ) ;
49
45
_options = new LanguageServerOptions ( )
50
46
. WithInput ( input )
51
47
. WithOutput ( output )
52
- . WithLoggerFactory ( _loggerFactory )
53
- . AddDefaultLoggingProvider ( )
48
+ . ConfigureLogging ( x => x
49
+ . AddLanguageServer ( )
50
+ . SetMinimumLevel ( application . LogLevel ) )
54
51
. OnInitialize ( Initialize )
55
- . WithMinimumLogLevel ( application . LogLevel )
56
- . WithServices ( services => _services = services ) ;
52
+ . WithServices ( services => {
53
+ _services = services ;
54
+ } ) ;
55
+
57
56
_application = application ;
58
57
_cancellationTokenSource = cancellationTokenSource ;
59
58
}
60
59
61
60
public void Dispose ( )
62
61
{
63
62
_compositionHost ? . Dispose ( ) ;
64
- _loggerFactory ? . Dispose ( ) ;
65
63
_cancellationTokenSource ? . Dispose ( ) ;
66
64
}
67
65
@@ -93,6 +91,9 @@ private void CreateCompositionHost(InitializeParams initializeParams)
93
91
_eventEmitter = new LanguageServerEventEmitter ( ) ;
94
92
_serviceProvider = CompositionHostBuilder . CreateDefaultServiceProvider ( _environment , configurationRoot , _eventEmitter , _services ) ;
95
93
94
+ var loggerFactory = _serviceProvider . GetService < ILoggerFactory > ( ) ;
95
+ _logger = loggerFactory . CreateLogger < LanguageServerHost > ( ) ;
96
+
96
97
var options = _serviceProvider . GetRequiredService < IOptionsMonitor < OmniSharpOptions > > ( ) ;
97
98
var plugins = _application . CreatePluginAssemblies ( options . CurrentValue , _environment ) ;
98
99
0 commit comments