Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b585308

Browse files
JustinGroteandyleejordan
authored andcommitted
Update PsesLogLevel to match MEL levels
1 parent 455ca1c commit b585308

File tree

4 files changed

+43
-18
lines changed

4 files changed

+43
-18
lines changed

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ $command = @(
8787
"-HostName 'My Client'",
8888
"-HostProfileId 'myclient'",
8989
"-HostVersion 1.0.0",
90-
"-LogLevel Diagnostic"
90+
"-LogLevel Trace"
9191
) -join " "
9292
9393
$pwsh_arguments = "-NoLogo -NoProfile -Command $command"

‎src/PowerShellEditorServices.Hosting/Commands/StartEditorServicesCommand.cs‎

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public StartEditorServicesCommand()
138138
/// The minimum log level that should be emitted.
139139
/// </summary>
140140
[Parameter]
141-
public PsesLogLevel LogLevel { get; set; } = PsesLogLevel.Warning;
141+
public string LogLevel { get; set; } = PsesLogLevel.Warning.ToString();
142142

143143
/// <summary>
144144
/// Paths to additional PowerShell modules to be imported at startup.
@@ -195,6 +195,11 @@ public StartEditorServicesCommand()
195195
[Parameter]
196196
public string StartupBanner { get; set; }
197197

198+
/// <summary>
199+
/// Compatibility to store the currently supported PSESLogLevel Enum Value
200+
/// </summary>
201+
private PsesLogLevel _psesLogLevel = PsesLogLevel.Warning;
202+
198203
#pragma warning disable IDE0022
199204
protected override void BeginProcessing()
200205
{
@@ -257,7 +262,25 @@ protected override void EndProcessing()
257262

258263
private void StartLogging()
259264
{
260-
_logger = new HostLogger(LogLevel);
265+
bool isLegacyPsesLogLevel = false;
266+
if (!Enum.TryParse(LogLevel, true, out _psesLogLevel))
267+
{
268+
// PSES used to have log levels that didn't match MEL levels, this is an adapter for those types and may eventually be removed once people migrate their settings.
269+
isLegacyPsesLogLevel = true;
270+
_psesLogLevel = LogLevel switch
271+
{
272+
"Diagnostic" => PsesLogLevel.Trace,
273+
"Verbose" => PsesLogLevel.Debug,
274+
"Normal" => PsesLogLevel.Information,
275+
_ => PsesLogLevel.Trace
276+
};
277+
}
278+
279+
_logger = new HostLogger(_psesLogLevel);
280+
if (isLegacyPsesLogLevel)
281+
{
282+
_logger.Log(PsesLogLevel.Warning, $"The log level '{LogLevel}' is deprecated and will be removed in a future release. Please update your settings or command line options to use one of the following options: 'Trace', 'Debug', 'Information', 'Warning', 'Error', 'Critical'.");
283+
}
261284

262285
// We need to not write log messages to Stdio
263286
// if it's being used as a protocol transport
@@ -349,7 +372,7 @@ private EditorServicesConfig CreateConfigObject()
349372
LogPath)
350373
{
351374
FeatureFlags = FeatureFlags,
352-
LogLevel = LogLevel,
375+
LogLevel = _psesLogLevel,
353376
ConsoleRepl = GetReplKind(),
354377
UseNullPSHostUI = Stdio, // If Stdio is used we can't write anything else out
355378
AdditionalModules = AdditionalModules,

‎src/PowerShellEditorServices.Hosting/EditorServicesLoader.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,10 @@ public Task LoadAndRunEditorServicesAsync()
212212
ValidateConfiguration();
213213

214214
// Method with no implementation that forces the PSES assembly to load, triggering an AssemblyResolve event
215-
_logger.Log(PsesLogLevel.Debug, "Loading PowerShell Editor Services");
215+
_logger.Log(PsesLogLevel.Information, "Loading PowerShell Editor Services");
216216
LoadEditorServices();
217217

218-
_logger.Log(PsesLogLevel.Debug, "Starting EditorServices");
218+
_logger.Log(PsesLogLevel.Information, "Starting EditorServices");
219219

220220
_editorServicesRunner = new EditorServicesRunner(_logger, _hostConfig, _sessionFileWriter, _loggersToUnsubscribe);
221221

‎src/PowerShellEditorServices.Hosting/Internal/EditorServicesRunner.cs‎

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public Task RunUntilShutdown()
6464
_sessionFileWriter.WriteSessionStarted(_config.LanguageServiceTransport, _config.DebugServiceTransport);
6565

6666
// Finally, wait for Editor Services to shut down
67-
_logger.Log(PsesLogLevel.Trace, "Waiting on PSES run/shutdown");
67+
_logger.Log(PsesLogLevel.Debug, "Waiting on PSES run/shutdown");
6868
return runAndAwaitShutdown;
6969
}
7070

@@ -124,7 +124,7 @@ private async Task CreateEditorServicesAndRunUntilShutdown()
124124
{
125125
try
126126
{
127-
_logger.Log(PsesLogLevel.Trace, "Creating/running editor services");
127+
_logger.Log(PsesLogLevel.Debug, "Creating/running editor services");
128128

129129
bool creatingLanguageServer = _config.LanguageServiceTransport != null;
130130
bool creatingDebugServer = _config.DebugServiceTransport != null;
@@ -140,6 +140,9 @@ private async Task CreateEditorServicesAndRunUntilShutdown()
140140
return;
141141
}
142142

143+
_logger.Log(PsesLogLevel.Information, "PSES Startup Completed. Starting Language Server.");
144+
_logger.Log(PsesLogLevel.Information, "Please check the LSP log file in your client for further messages. In VSCode, this is the 'PowerShell' output pane");
145+
143146
// We want LSP and maybe debugging
144147
// To do that we:
145148
// - Create the LSP server
@@ -149,7 +152,6 @@ private async Task CreateEditorServicesAndRunUntilShutdown()
149152
// - Wait for the LSP server to finish
150153

151154
// Unsubscribe the host logger here so that the Extension Terminal is not polluted with input after the first prompt
152-
_logger.Log(PsesLogLevel.Debug, "Starting server, deregistering host logger and registering shutdown listener");
153155
if (_loggersToUnsubscribe != null)
154156
{
155157
foreach (IDisposable loggerToUnsubscribe in _loggersToUnsubscribe)
@@ -193,7 +195,7 @@ private async Task CreateEditorServicesAndRunUntilShutdown()
193195

194196
private async Task RunTempDebugSessionAsync(HostStartupInfo hostDetails)
195197
{
196-
_logger.Log(PsesLogLevel.Trace, "Running temp debug session");
198+
_logger.Log(PsesLogLevel.Information, "Starting temporary debug session");
197199
PsesDebugServer debugServer = await CreateDebugServerForTempSessionAsync(hostDetails).ConfigureAwait(false);
198200
_logger.Log(PsesLogLevel.Debug, "Debug server created");
199201
await debugServer.StartAsync().ConfigureAwait(false);
@@ -222,35 +224,35 @@ private async Task StartDebugServer(Task<PsesDebugServer> debugServerCreation)
222224

223225
private Task RestartDebugServerAsync(PsesDebugServer debugServer)
224226
{
225-
_logger.Log(PsesLogLevel.Trace, "Restarting debug server");
227+
_logger.Log(PsesLogLevel.Debug, "Restarting debug server");
226228
Task<PsesDebugServer> debugServerCreation = RecreateDebugServerAsync(debugServer);
227229
return StartDebugServer(debugServerCreation);
228230
}
229231

230232
private async Task<PsesLanguageServer> CreateLanguageServerAsync(HostStartupInfo hostDetails)
231233
{
232-
_logger.Log(PsesLogLevel.Debug, $"Creating LSP transport with endpoint {_config.LanguageServiceTransport.EndpointDetails}");
234+
_logger.Log(PsesLogLevel.Trace, $"Creating LSP transport with endpoint {_config.LanguageServiceTransport.EndpointDetails}");
233235
(Stream inStream, Stream outStream) = await _config.LanguageServiceTransport.ConnectStreamsAsync().ConfigureAwait(false);
234236

235-
_logger.Log(PsesLogLevel.Trace, "Creating language server");
237+
_logger.Log(PsesLogLevel.Debug, "Creating language server");
236238
return _serverFactory.CreateLanguageServer(inStream, outStream, hostDetails);
237239
}
238240

239241
private async Task<PsesDebugServer> CreateDebugServerWithLanguageServerAsync(PsesLanguageServer languageServer)
240242
{
241-
_logger.Log(PsesLogLevel.Debug, $"Creating debug adapter transport with endpoint {_config.DebugServiceTransport.EndpointDetails}");
243+
_logger.Log(PsesLogLevel.Trace, $"Creating debug adapter transport with endpoint {_config.DebugServiceTransport.EndpointDetails}");
242244
(Stream inStream, Stream outStream) = await _config.DebugServiceTransport.ConnectStreamsAsync().ConfigureAwait(false);
243245

244-
_logger.Log(PsesLogLevel.Trace, "Creating debug adapter");
246+
_logger.Log(PsesLogLevel.Debug, "Creating debug adapter");
245247
return _serverFactory.CreateDebugServerWithLanguageServer(inStream, outStream, languageServer);
246248
}
247249

248250
private async Task<PsesDebugServer> RecreateDebugServerAsync(PsesDebugServer debugServer)
249251
{
250-
_logger.Log(PsesLogLevel.Trace, "Recreating debug adapter transport");
252+
_logger.Log(PsesLogLevel.Debug, "Recreating debug adapter transport");
251253
(Stream inStream, Stream outStream) = await _config.DebugServiceTransport.ConnectStreamsAsync().ConfigureAwait(false);
252254

253-
_logger.Log(PsesLogLevel.Trace, "Recreating debug adapter");
255+
_logger.Log(PsesLogLevel.Debug, "Recreating debug adapter");
254256
return _serverFactory.RecreateDebugServer(inStream, outStream, debugServer);
255257
}
256258

@@ -263,7 +265,7 @@ private async Task<PsesDebugServer> CreateDebugServerForTempSessionAsync(HostSta
263265

264266
private HostStartupInfo CreateHostStartupInfo()
265267
{
266-
_logger.Log(PsesLogLevel.Trace, "Creating startup info object");
268+
_logger.Log(PsesLogLevel.Debug, "Creating startup info object");
267269

268270
ProfilePathInfo profilePaths = null;
269271
if (_config.ProfilePaths.AllUsersAllHosts != null

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /