Skip to content

Commit a6c62bf

Browse files
committed
[Feature] Minor changes to make ScriptBlock logging work with SysLog
1 parent 117e83a commit a6c62bf

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

src/System.Management.Automation/utils/tracing/SysLogProvider.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,13 @@ public void SetActivity(Guid activity)
313313
/// <param name="args">The payload for the log message.</param>
314314
public void Log(PSEventId eventId, PSChannel channel, PSTask task, PSOpcode opcode, PSLevel level, PSKeyword keyword, params object[] args)
315315
{
316+
if (keyword == PSKeyword.UseAlwaysAnalytic)
317+
{
318+
// Use the 'DefaultKeywords' to work around the default keyword filter.
319+
// Note that the PSKeyword argument is not really used in writing SysLog.
320+
keyword = PSSysLogProvider.DefaultKeywords;
321+
}
322+
316323
if (ShouldLog(level, keyword, channel))
317324
{
318325
int threadId = Thread.CurrentThread.ManagedThreadId;

test/csharp/test_PSConfiguration.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ public PowerShellPolicyFixture()
3333
systemWideConfigDirectory = Utils.DefaultPowerShellAppBase;
3434
currentUserConfigDirectory = Utils.GetUserConfigurationDirectory();
3535

36+
if (!Directory.Exists(currentUserConfigDirectory))
37+
{
38+
// Create the CurrentUser config directory if it doesn't exist
39+
Directory.CreateDirectory(currentUserConfigDirectory);
40+
}
41+
3642
systemWideConfigFile = Path.Combine(systemWideConfigDirectory, "PowerShellProperties.json");
3743
currentUserConfigFile = Path.Combine(currentUserConfigDirectory, "PowerShellProperties.json");
3844

0 commit comments

Comments
 (0)