Skip to content

Commit 455ca1c

Browse files
JustinGroteandyleejordan
authored andcommitted
Update Log Levels for PSES Appropriately
1 parent d9de5bd commit 455ca1c

File tree

7 files changed

+78
-79
lines changed

7 files changed

+78
-79
lines changed

src/PowerShellEditorServices.Hosting/Commands/StartEditorServicesCommand.cs

Lines changed: 16 additions & 16 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.Normal;
141+
public PsesLogLevel LogLevel { get; set; } = PsesLogLevel.Warning;
142142

143143
/// <summary>
144144
/// Paths to additional PowerShell modules to be imported at startup.
@@ -218,7 +218,7 @@ protected override void BeginProcessing()
218218
[System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "VSTHRD002:Avoid problematic synchronous waits", Justification = "We have to wait here, it's the whole program.")]
219219
protected override void EndProcessing()
220220
{
221-
_logger.Log(PsesLogLevel.Diagnostic, "Beginning EndProcessing block");
221+
_logger.Log(PsesLogLevel.Trace, "Beginning EndProcessing block");
222222
try
223223
{
224224
// First try to remove PSReadLine to decomplicate startup
@@ -229,7 +229,7 @@ protected override void EndProcessing()
229229
EditorServicesConfig editorServicesConfig = CreateConfigObject();
230230

231231
using EditorServicesLoader psesLoader = EditorServicesLoader.Create(_logger, editorServicesConfig, SessionDetailsPath, _loggerUnsubscribers);
232-
_logger.Log(PsesLogLevel.Verbose, "Loading EditorServices");
232+
_logger.Log(PsesLogLevel.Debug, "Loading EditorServices");
233233
// Synchronously start editor services and wait here until it shuts down.
234234
psesLoader.LoadAndRunEditorServicesAsync().GetAwaiter().GetResult();
235235
}
@@ -281,7 +281,7 @@ private void StartLogging()
281281
IDisposable fileLoggerUnsubscriber = _logger.Subscribe(fileLogger);
282282
fileLogger.AddUnsubscriber(fileLoggerUnsubscriber);
283283
_loggerUnsubscribers.Add(fileLoggerUnsubscriber);
284-
_logger.Log(PsesLogLevel.Diagnostic, "Logging started");
284+
_logger.Log(PsesLogLevel.Trace, "Logging started");
285285
}
286286

287287
// Sanitizes user input and ensures the directory is created.
@@ -299,7 +299,7 @@ private string GetLogDirPath()
299299

300300
private void RemovePSReadLineForStartup()
301301
{
302-
_logger.Log(PsesLogLevel.Verbose, "Removing PSReadLine");
302+
_logger.Log(PsesLogLevel.Debug, "Removing PSReadLine");
303303
using SMA.PowerShell pwsh = SMA.PowerShell.Create(RunspaceMode.CurrentRunspace);
304304
bool hasPSReadLine = pwsh.AddCommand(new CmdletInfo(@"Microsoft.PowerShell.Core\Get-Module", typeof(GetModuleCommand)))
305305
.AddParameter("Name", "PSReadLine")
@@ -314,13 +314,13 @@ private void RemovePSReadLineForStartup()
314314
.AddParameter("Name", "PSReadLine")
315315
.AddParameter("ErrorAction", "SilentlyContinue");
316316

317-
_logger.Log(PsesLogLevel.Verbose, "Removed PSReadLine");
317+
_logger.Log(PsesLogLevel.Debug, "Removed PSReadLine");
318318
}
319319
}
320320

321321
private EditorServicesConfig CreateConfigObject()
322322
{
323-
_logger.Log(PsesLogLevel.Diagnostic, "Creating host configuration");
323+
_logger.Log(PsesLogLevel.Trace, "Creating host configuration");
324324

325325
string bundledModulesPath = BundledModulesPath;
326326
if (!Path.IsPathRooted(bundledModulesPath))
@@ -399,31 +399,31 @@ private string GetProfilePathFromProfileObject(PSObject profileObject, ProfileUs
399399
// * On Linux or macOS on any version greater than or equal to 7
400400
private ConsoleReplKind GetReplKind()
401401
{
402-
_logger.Log(PsesLogLevel.Diagnostic, "Determining REPL kind");
402+
_logger.Log(PsesLogLevel.Trace, "Determining REPL kind");
403403

404404
if (Stdio || !EnableConsoleRepl)
405405
{
406-
_logger.Log(PsesLogLevel.Diagnostic, "REPL configured as None");
406+
_logger.Log(PsesLogLevel.Trace, "REPL configured as None");
407407
return ConsoleReplKind.None;
408408
}
409409

410410
if (UseLegacyReadLine)
411411
{
412-
_logger.Log(PsesLogLevel.Diagnostic, "REPL configured as Legacy");
412+
_logger.Log(PsesLogLevel.Trace, "REPL configured as Legacy");
413413
return ConsoleReplKind.LegacyReadLine;
414414
}
415415

416-
_logger.Log(PsesLogLevel.Diagnostic, "REPL configured as PSReadLine");
416+
_logger.Log(PsesLogLevel.Trace, "REPL configured as PSReadLine");
417417
return ConsoleReplKind.PSReadLine;
418418
}
419419

420420
private ITransportConfig GetLanguageServiceTransport()
421421
{
422-
_logger.Log(PsesLogLevel.Diagnostic, "Configuring LSP transport");
422+
_logger.Log(PsesLogLevel.Trace, "Configuring LSP transport");
423423

424424
if (DebugServiceOnly)
425425
{
426-
_logger.Log(PsesLogLevel.Diagnostic, "No LSP transport: PSES is debug only");
426+
_logger.Log(PsesLogLevel.Trace, "No LSP transport: PSES is debug only");
427427
return null;
428428
}
429429

@@ -447,11 +447,11 @@ private ITransportConfig GetLanguageServiceTransport()
447447

448448
private ITransportConfig GetDebugServiceTransport()
449449
{
450-
_logger.Log(PsesLogLevel.Diagnostic, "Configuring debug transport");
450+
_logger.Log(PsesLogLevel.Trace, "Configuring debug transport");
451451

452452
if (LanguageServiceOnly)
453453
{
454-
_logger.Log(PsesLogLevel.Diagnostic, "No Debug transport: PSES is language service only");
454+
_logger.Log(PsesLogLevel.Trace, "No Debug transport: PSES is language service only");
455455
return null;
456456
}
457457

@@ -462,7 +462,7 @@ private ITransportConfig GetDebugServiceTransport()
462462
return new StdioTransportConfig(_logger);
463463
}
464464

465-
_logger.Log(PsesLogLevel.Diagnostic, "No debug transport: Transport is Stdio with debug disabled");
465+
_logger.Log(PsesLogLevel.Trace, "No debug transport: Transport is Stdio with debug disabled");
466466
return null;
467467
}
468468

src/PowerShellEditorServices.Hosting/Configuration/EditorServicesConfig.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,14 @@ public EditorServicesConfig(
9090
public ConsoleReplKind ConsoleRepl { get; set; } = ConsoleReplKind.None;
9191

9292
/// <summary>
93-
/// Will suppress messages to PSHost (to prevent Stdio clobbering)
93+
/// Will suppress messages to PSHost (to prevent Stdio clobbering)
9494
/// </summary>
9595
public bool UseNullPSHostUI { get; set; }
9696

9797
/// <summary>
98-
/// The minimum log level to log events with.
98+
/// The minimum log level to log events with. Defaults to warning but is usually overriden by the startup process.
9999
/// </summary>
100-
public PsesLogLevel LogLevel { get; set; } = PsesLogLevel.Normal;
100+
public PsesLogLevel LogLevel { get; set; } = PsesLogLevel.Warning;
101101

102102
/// <summary>
103103
/// Configuration for the language server protocol transport to use.

src/PowerShellEditorServices.Hosting/Configuration/SessionFileWriter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public SessionFileWriter(HostLogger logger, string sessionFilePath, Version powe
6363
/// <param name="reason">The reason for the startup failure.</param>
6464
public void WriteSessionFailure(string reason)
6565
{
66-
_logger.Log(PsesLogLevel.Diagnostic, "Writing session failure");
66+
_logger.Log(PsesLogLevel.Trace, "Writing session failure");
6767

6868
Dictionary<string, object> sessionObject = new()
6969
{
@@ -81,7 +81,7 @@ public void WriteSessionFailure(string reason)
8181
/// <param name="debugAdapterTransport">The debug adapter transport configuration.</param>
8282
public void WriteSessionStarted(ITransportConfig languageServiceTransport, ITransportConfig debugAdapterTransport)
8383
{
84-
_logger.Log(PsesLogLevel.Diagnostic, "Writing session started");
84+
_logger.Log(PsesLogLevel.Trace, "Writing session started");
8585

8686
Dictionary<string, object> sessionObject = new()
8787
{
@@ -142,7 +142,7 @@ private void WriteSessionObject(Dictionary<string, object> sessionObject)
142142
File.WriteAllText(_sessionFilePath, content, s_sessionFileEncoding);
143143
}
144144

145-
_logger.Log(PsesLogLevel.Verbose, $"Session file written to {_sessionFilePath} with content:\n{content}");
145+
_logger.Log(PsesLogLevel.Debug, $"Session file written to {_sessionFilePath} with content:\n{content}");
146146
}
147147
}
148148
}

src/PowerShellEditorServices.Hosting/Configuration/TransportConfig.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public sealed class StdioTransportConfig : ITransportConfig
5353

5454
public Task<(Stream inStream, Stream outStream)> ConnectStreamsAsync()
5555
{
56-
_logger.Log(PsesLogLevel.Diagnostic, "Connecting stdio streams");
56+
_logger.Log(PsesLogLevel.Trace, "Connecting stdio streams");
5757
return Task.FromResult((Console.OpenStandardInput(), Console.OpenStandardOutput()));
5858
}
5959
}
@@ -102,11 +102,11 @@ private DuplexNamedPipeTransportConfig(HostLogger logger, string pipeName)
102102

103103
public async Task<(Stream inStream, Stream outStream)> ConnectStreamsAsync()
104104
{
105-
_logger.Log(PsesLogLevel.Diagnostic, "Creating named pipe");
105+
_logger.Log(PsesLogLevel.Trace, "Creating named pipe");
106106
NamedPipeServerStream namedPipe = NamedPipeUtils.CreateNamedPipe(_pipeName, PipeDirection.InOut);
107-
_logger.Log(PsesLogLevel.Diagnostic, "Waiting for named pipe connection");
107+
_logger.Log(PsesLogLevel.Trace, "Waiting for named pipe connection");
108108
await namedPipe.WaitForConnectionAsync().ConfigureAwait(false);
109-
_logger.Log(PsesLogLevel.Diagnostic, "Named pipe connected");
109+
_logger.Log(PsesLogLevel.Trace, "Named pipe connected");
110110
return (namedPipe, namedPipe);
111111
}
112112
}
@@ -173,18 +173,18 @@ private SimplexNamedPipeTransportConfig(HostLogger logger, string inPipeName, st
173173

174174
public async Task<(Stream inStream, Stream outStream)> ConnectStreamsAsync()
175175
{
176-
_logger.Log(PsesLogLevel.Diagnostic, "Starting in pipe connection");
176+
_logger.Log(PsesLogLevel.Trace, "Starting in pipe connection");
177177
NamedPipeServerStream inPipe = NamedPipeUtils.CreateNamedPipe(_inPipeName, PipeDirection.InOut);
178178
Task inPipeConnected = inPipe.WaitForConnectionAsync();
179179

180-
_logger.Log(PsesLogLevel.Diagnostic, "Starting out pipe connection");
180+
_logger.Log(PsesLogLevel.Trace, "Starting out pipe connection");
181181
NamedPipeServerStream outPipe = NamedPipeUtils.CreateNamedPipe(_outPipeName, PipeDirection.Out);
182182
Task outPipeConnected = outPipe.WaitForConnectionAsync();
183183

184-
_logger.Log(PsesLogLevel.Diagnostic, "Wating for pipe connections");
184+
_logger.Log(PsesLogLevel.Trace, "Wating for pipe connections");
185185
await Task.WhenAll(inPipeConnected, outPipeConnected).ConfigureAwait(false);
186186

187-
_logger.Log(PsesLogLevel.Diagnostic, "Simplex named pipe transport connected");
187+
_logger.Log(PsesLogLevel.Trace, "Simplex named pipe transport connected");
188188
return (inPipe, outPipe);
189189
}
190190
}

0 commit comments

Comments
 (0)