Skip to content

Commit a482151

Browse files
Merge pull request #267 from PowershellFrameworkCollective/runspaceVariableObject
Updates to message, logging & Select-PSFObject experience
2 parents 63af1d3 + f2c630d commit a482151

13 files changed

Lines changed: 865 additions & 121 deletions

File tree

PSFramework/bin/PSFramework.dll

512 Bytes
Binary file not shown.

PSFramework/bin/PSFramework.pdb

4 KB
Binary file not shown.

PSFramework/bin/PSFramework.xml

Lines changed: 77 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PSFramework/changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# CHANGELOG
22
## ???
33
- New: Configuration validation: Credential. Validates PSCredential objects.
4+
- New: The most awesome Tab Completion for input properties _ever_ .
45
- Upd: Write-PSFMessage supports localized strings through the `-String` and `-StringValues` parameters
56
- Upd: Stop-PSFFunction supports localized strings through the `-String` and `-StringValues` parameters
67
- Upd: Test-PSFShouldProcess now supports ShouldProcess itself. This should help silence tests on commands reyling on it.
78
- Upd: Message component supports localized strings
89
- Upd: Logging component logs in separate language than localized messages to screen / userinteraction
10+
- Upd: Logging - filesystem provider now has a configuration to enable better output information: `psframework.logging.filesystem.modernlog`
911
- Upd: Import-PSFLocalizedString now accepts wildcard path patterns that resovle to multiple files.
1012
- Upd: Adding tab completion for `Register-PSFTeppArgumentCompleter`
1113
- fix: Missing localization strings - Fix: Missing tab completion for modules that register localized strings
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
#region Setting the configuration
2-
Set-PSFConfig -Module PSFramework -Name 'Logging.MaxErrorCount' -Value 128 -Initialize -Validation "integerpositive" -Handler { [PSFramework.Message.LogHost]::MaxErrorCount = $args[0] } -Description "The maximum number of error records maintained in-memory. This setting is on a per-Process basis. Runspaces share, jobs or other consoles counted separately."
1+
Set-PSFConfig -Module PSFramework -Name 'Logging.MaxErrorCount' -Value 128 -Initialize -Validation "integerpositive" -Handler { [PSFramework.Message.LogHost]::MaxErrorCount = $args[0] } -Description "The maximum number of error records maintained in-memory. This setting is on a per-Process basis. Runspaces share, jobs or other consoles counted separately."
32
Set-PSFConfig -Module PSFramework -Name 'Logging.MaxMessageCount' -Value 1024 -Initialize -Validation "integerpositive" -Handler { [PSFramework.Message.LogHost]::MaxMessageCount = $args[0] } -Description "The maximum number of messages that can be maintained in the in-memory message queue. This setting is on a per-Process basis. Runspaces share, jobs or other consoles counted separately."
43
Set-PSFConfig -Module PSFramework -Name 'Logging.MessageLogEnabled' -Value $true -Initialize -Validation "bool" -Handler { [PSFramework.Message.LogHost]::MessageLogEnabled = $args[0] } -Description "Governs, whether a log of recent messages is kept in memory. This setting is on a per-Process basis. Runspaces share, jobs or other consoles counted separately."
54
Set-PSFConfig -Module PSFramework -Name 'Logging.ErrorLogEnabled' -Value $true -Initialize -Validation "bool" -Handler { [PSFramework.Message.LogHost]::ErrorLogEnabled = $args[0] } -Description "Governs, whether a log of recent errors is kept in memory. This setting is on a per-Process basis. Runspaces share, jobs or other consoles counted separately."
6-
Set-PSFConfig -Module PSFramework -Name 'Logging.DisableLogFlush' -Value $false -Initialize -Validation "bool" -Handler { } -Description "When shutting down the process, PSFramework will by default flush the log. This ensures that all events are properly logged. If this is not desired, it can be turned off with this setting."
7-
#endregion Setting the configuration
5+
Set-PSFConfig -Module PSFramework -Name 'Logging.DisableLogFlush' -Value $false -Initialize -Validation "bool" -Handler { } -Description "When shutting down the process, PSFramework will by default flush the log. This ensures that all events are properly logged. If this is not desired, it can be turned off with this setting."

PSFramework/internal/loggingProviders/filesystem.provider.ps1

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,15 @@ $message_Event = {
116116

117117
if ($Message)
118118
{
119-
Add-Content -Path $filesystem_CurrentFile -Value (ConvertTo-Csv ($Message | Select-PSFObject ComputerName, Timestamp, Level, 'LogMessage as Message', Type, FunctionName, ModuleName, File, Line, @{ n = "Tags"; e = { $_.Tags -join "," } }, TargetObject, Runspace) -NoTypeInformation)[1]
119+
if ([PSFramework.Message.LogHost]::FileSystemModernLog)
120+
{
121+
if (-not (Test-Path $filesystem_CurrentFile))
122+
{
123+
$Message | Select-PSFObject ComputerName, Username, Timestamp, Level, 'LogMessage as Message', Type, FunctionName, ModuleName, File, Line, @{ n = "Tags"; e = { $_.Tags -join "," } }, TargetObject, Runspace, @{ n = "Callstack"; e = { $_.CallStack.ToString().Split("`n") -join " þ "} } | Export-Csv -Path $filesystem_CurrentFile -NoTypeInformation
124+
}
125+
else { Add-Content -Path $filesystem_CurrentFile -Value (ConvertTo-Csv ($Message | Select-PSFObject ComputerName, Username, Timestamp, Level, 'LogMessage as Message', Type, FunctionName, ModuleName, File, Line, @{ n = "Tags"; e = { $_.Tags -join "," } }, TargetObject, Runspace, @{ n = "Callstack"; e = { $_.CallStack.ToString().Split("`n") -join " þ " } }) -NoTypeInformation)[1] }
126+
}
127+
else { Add-Content -Path $filesystem_CurrentFile -Value (ConvertTo-Csv ($Message | Select-PSFObject ComputerName, Timestamp, Level, 'LogMessage as Message', Type, FunctionName, ModuleName, File, Line, @{ n = "Tags"; e = { $_.Tags -join "," } }, TargetObject, Runspace) -NoTypeInformation)[1] }
120128
}
121129
}
122130

@@ -209,6 +217,7 @@ $configuration_Settings = {
209217
Set-PSFConfig -Module PSFramework -Name 'Logging.FileSystem.MaxLogFileAge' -Value (New-TimeSpan -Days 7) -Initialize -Validation "timespan" -Handler { [PSFramework.Message.LogHost]::MaxLogFileAge = $args[0] } -Description "Any logfile older than this will automatically be cleansed. This setting is global."
210218
Set-PSFConfig -Module PSFramework -Name 'Logging.FileSystem.MessageLogFileEnabled' -Value $true -Initialize -Validation "bool" -Handler { [PSFramework.Message.LogHost]::MessageLogFileEnabled = $args[0] } -Description "Governs, whether a log file for the system messages is written. This setting is on a per-Process basis. Runspaces share, jobs or other consoles counted separately."
211219
Set-PSFConfig -Module PSFramework -Name 'Logging.FileSystem.ErrorLogFileEnabled' -Value $true -Initialize -Validation "bool" -Handler { [PSFramework.Message.LogHost]::ErrorLogFileEnabled = $args[0] } -Description "Governs, whether log files for errors are written. This setting is on a per-Process basis. Runspaces share, jobs or other consoles counted separately."
220+
Set-PSFConfig -Module PSFramework -Name 'Logging.FileSystem.ModernLog' -Value $false -Initialize -Validation "bool" -Handler { [PSFramework.Message.LogHost]::FileSystemModernLog = $args[0] } -Description "Enables the modern, more powereful version of the filesystem log, including headers and extra columns"
212221
Set-PSFConfig -Module PSFramework -Name 'Logging.FileSystem.LogPath' -Value $script:path_Logging -Initialize -Validation "string" -Handler { [PSFramework.Message.LogHost]::LoggingPath = $args[0] } -Description "The path where the PSFramework writes all its logs and debugging information."
213222

214223
Set-PSFConfig -Module LoggingProvider -Name 'FileSystem.Enabled' -Value $true -Initialize -Validation "bool" -Handler { if ([PSFramework.Logging.ProviderHost]::Providers['filesystem']) { [PSFramework.Logging.ProviderHost]::Providers['filesystem'].Enabled = $args[0] } } -Description "Whether the logging provider should be enabled on registration"

PSFramework/internal/scripts/postimport.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,11 @@ foreach ($file in (Get-ChildItem -Path "$($script:ModuleRoot)\internal\parameter
4848
# Register the unimport reaction
4949
. Import-ModuleFile -Path "$($script:ModuleRoot)\internal\scripts\removalEvent.ps1"
5050

51-
# Load specialvariables
51+
# Load special variables
5252
. Import-ModuleFile -Path "$($script:ModuleRoot)\internal\scripts\variables.ps1"
5353

54+
# Load resources for TEPP input completion
55+
. Import-ModuleFile -Path "$($script:ModuleRoot)\internal\scripts\teppInputResources.ps1"
56+
5457
# Finally register the license
5558
. Import-ModuleFile -Path "$($script:ModuleRoot)\internal\scripts\license.ps1"
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
[PSFramework.TabExpansion.TabExpansionHost]::InputCompletionTypeData['System.IO.FileInfo'] = @(
2+
[PSCustomObject]@{
3+
Name = 'PSChildName'
4+
Type = ([type]'System.String')
5+
TypeKnown = $true
6+
},
7+
[PSCustomObject]@{
8+
Name = 'PSDrive'
9+
Type = ([type]'System.Management.Automation.PSDriveInfo')
10+
TypeKnown = $true
11+
},
12+
[PSCustomObject]@{
13+
Name = 'PSIsContainer'
14+
Type = ([type]'System.Boolean')
15+
TypeKnown = $true
16+
},
17+
[PSCustomObject]@{
18+
Name = 'PSParentPath'
19+
Type = ([type]'System.String')
20+
TypeKnown = $true
21+
},
22+
[PSCustomObject]@{
23+
Name = 'PSPath'
24+
Type = ([type]'System.String')
25+
TypeKnown = $true
26+
},
27+
[PSCustomObject]@{
28+
Name = 'PSProvider'
29+
Type = ([type]'System.Management.Automation.ProviderInfo')
30+
TypeKnown = $true
31+
},
32+
[PSCustomObject]@{
33+
Name = 'BaseName'
34+
Type = ([type]'System.String')
35+
TypeKnown = $true
36+
},
37+
[PSCustomObject]@{
38+
Name = 'VersionInfo'
39+
Type = ([type]'System.Diagnostics.FileVersionInfo')
40+
TypeKnown = $true
41+
}
42+
)
43+
44+
[PSFramework.TabExpansion.TabExpansionHost]::InputCompletionTypeData['System.IO.DirectoryInfo'] = @(
45+
[PSCustomObject]@{
46+
Name = 'PSChildName'
47+
Type = ([type]'System.String')
48+
TypeKnown = $true
49+
},
50+
[PSCustomObject]@{
51+
Name = 'PSDrive'
52+
Type = ([type]'System.Management.Automation.PSDriveInfo')
53+
TypeKnown = $true
54+
},
55+
[PSCustomObject]@{
56+
Name = 'PSIsContainer'
57+
Type = ([type]'System.Boolean')
58+
TypeKnown = $true
59+
},
60+
[PSCustomObject]@{
61+
Name = 'PSParentPath'
62+
Type = ([type]'System.String')
63+
TypeKnown = $true
64+
},
65+
[PSCustomObject]@{
66+
Name = 'PSPath'
67+
Type = ([type]'System.String')
68+
TypeKnown = $true
69+
},
70+
[PSCustomObject]@{
71+
Name = 'PSProvider'
72+
Type = ([type]'System.Management.Automation.ProviderInfo')
73+
TypeKnown = $true
74+
},
75+
[PSCustomObject]@{
76+
Name = 'BaseName'
77+
Type = ([type]'System.String')
78+
TypeKnown = $true
79+
}
80+
)

0 commit comments

Comments
 (0)