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

Trying the TL;DR example as stated fails with multiple errors #72

Closed
turturis opened this issue Sep 19, 2019 · 1 comment
Closed

Trying the TL;DR example as stated fails with multiple errors #72

turturis opened this issue Sep 19, 2019 · 1 comment

Comments

@turturis
Copy link

Following the TL;DR basic example explicitly (literally copy pasta) from https://logging.readthedocs.io/en/latest/ fails with the following errors:

Exception calling ".ctor" with "1" argument(s): "Cannot process argument because the value of argument
"validValues" is out of range. Change argument "validValues" to a value that is within range.
Parameter name: validValues
Actual value was System.String[]."
At C:\Program Files\WindowsPowerShell\Modules\Logging\private\New-LoggingDynamicParam.ps1:80 char:5
$validateSetAttribute = [System.Management.Automation.ValidateSet ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : PSArgumentOutOfRangeException

Exception calling ".ctor" with "1" argument(s): "Cannot process argument because the value of argument
"validValues" is out of range. Change argument "validValues" to a value that is within range.
Parameter name: validValues
Actual value was System.String[]."
At C:\Program Files\WindowsPowerShell\Modules\Logging\private\New-LoggingDynamicParam.ps1:80 char:5
$validateSetAttribute = [System.Management.Automation.ValidateSet ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : PSArgumentOutOfRangeException

Level not a valid integer or a valid string:
Level not a valid integer or a valid string:
.
.
.
i stopped execution but i would be met with 98 more of the same "Level not a valid integer or a valid string:"

below is the code:

`Import-Module Logging

Set-LoggingDefaultLevel -Level 'WARNING'
Add-LoggingTarget -Name Console
Add-LoggingTarget -Name File -Configuration @{Path = 'C:\Temp\example_%{+%Y%m%d}.log'}

$Level = 'DEBUG', 'INFO', 'WARNING', 'ERROR'
foreach ($i in 1..100) {
Write-Log -Level ($Level | Get-Random) -Message 'Message n. {0}' -Arguments $i
Start-Sleep -Milliseconds (Get-Random -Min 100 -Max 1000)
}

Wait-Logging # See Note`

this was run from PowerGUI. i am met with same from console or ISE.

@turturis
Copy link
Author

it appears that using the link within the document to download the files vs issuing the Install-Module Logging is the issue. not sure why, but when i did the second option, it worked.

@turturis turturis reopened this Sep 19, 2019
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