Skip to content

Commit 2ce6b9c

Browse files
committed
Make exception logging work
1 parent 46fd4e6 commit 2ce6b9c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/PowerShellEditorServices/Utility/Logging.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,15 +193,15 @@ public PsesLogger Build()
193193
{
194194
configuration = configuration.WriteTo.Console(
195195
restrictedToMinimumLevel: ConvertLogLevel(_consoleLogLevel ?? _logLevel),
196-
outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff} {Message}{Newline}{Exception}");
196+
outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff} {Message}{Newline}{Exception}{Newline}");
197197
}
198198

199199
foreach (KeyValuePair<string, FileLogConfiguration> logFile in _filePaths)
200200
{
201201
configuration = configuration.WriteTo.Async(a => a.File(logFile.Key,
202202
restrictedToMinimumLevel: ConvertLogLevel(logFile.Value.logLevel ?? _logLevel),
203203
shared: logFile.Value.useMultiprocess,
204-
outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff} {Message}{Newline}{Exception}")
204+
outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff} {Message}{Newline}{Exception}{Newline}")
205205
);
206206
}
207207

@@ -314,19 +314,19 @@ public void Write(
314314
/// Log an exception in the logs.
315315
/// </summary>
316316
/// <param name="errorMessage">The error message of the exception to be logged.</param>
317-
/// <param name="errorException">The exception itself that has been thrown.</param>
317+
/// <param name="exception">The exception itself that has been thrown.</param>
318318
/// <param name="callerName">The name of the method in which the logger is being called.</param>
319319
/// <param name="callerSourceFile">The name of the source file in which the logger is being called.</param>
320320
/// <param name="callerLineNumber">The line number in the file where the logger is being called.</param>
321321
public void WriteException(
322322
string errorMessage,
323-
Exception errorException,
323+
Exception exception,
324324
[CallerMemberName] string callerName = null,
325325
[CallerFilePath] string callerSourceFile = null,
326326
[CallerLineNumber] int callerLineNumber = 0)
327327
{
328-
_logger.Error("[{Error:l}] {CallerSourceFile:l}: In '{CallerName:l}', line {CallerLineNumber}:\nException: {ErrorMessage:l}\n{ErrorException}",
329-
LogLevel.Error.ToString().ToUpper(), callerSourceFile, callerName, callerLineNumber, errorMessage, errorException);
328+
_logger.Error("[{Error:l}] {CallerSourceFile:l}: In '{CallerName:l}', line {CallerLineNumber}:\n {ErrorMessage:l}\n {Exception:l}\n",
329+
LogLevel.Error.ToString().ToUpper(), callerSourceFile, callerName, callerLineNumber, errorMessage, exception);
330330
}
331331

332332
/// <summary>
@@ -343,7 +343,7 @@ private static string IndentMsg(string logMessage)
343343
msgLines[i] = msgLines[i].Insert(0, " ");
344344
}
345345

346-
return String.Join("\n", msgLines);
346+
return String.Join("\n", msgLines)+"\n";
347347
}
348348

349349
#region IDisposable Support

0 commit comments

Comments
 (0)