Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is or should be the behavior of PowerShell sink with -Debug or -Verbose switch. #27

Open
adzero opened this issue Jun 17, 2022 · 0 comments

Comments

@adzero
Copy link

adzero commented Jun 17, 2022

I created a sample script to illustrate the outputs of a logger with both Console and PowerShell sinks :

[CmdletBinding()]
param()

Import-Module -Name PoShLog
New-Logger | 
	Set-MinimumLevel -Value Verbose |
	Add-SinkPowerShell -OutputTemplate "SinkPowerShell : {Message:lj}" | 
	Add-SinkConsole -OutputTemplate "SinkConsole : {Message:lj}{NewLine}" | 
	Start-Logger 
Write-Host "VERBOSE"
Write-VerboseLog "Test Verbose message : ($($VerbosePreference))"
Write-Host "DEBUG"
Write-DebugLog "Test Debug message : ($($DebugPreference))"
Write-Host "INFO"
Write-InfoLog "Test Information message : ($($InformationPreference))"
Write-Host "WARNING"
Write-WarningLog "Test Warning message : ($($WarningPreference))"
Write-Host "ERROR"
Write-ErrorLog "Test Error message"
Write-Host "FATAL"
Write-FatalLog "Test Fatal message."

Close-Logger

When I execute this script with default values for preferences variables and without any switch for Verbose, Debug, ... here is the output :

image

If I execute the script with a -Verbose switch (or another one), I thought the Verbose level output would be displayed by the PowerShell sink. It isn't whereas the value of the associated preference variable has actually changed to Continue :

image

If I set the $VerbosePreference variable to Continue before executing the script (or use the -ToParameters switch in ````Set-MinimumLevel``` the verbose log is displayed by the PowerShell sink.

image

Is this behavior normal ? If yes, what am I understanding wrong ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant