From a520ffb16c795a577c7b30931ed9fe2fc9e931c2 Mon Sep 17 00:00:00 2001 From: Raymond Piller Date: Mon, 9 Jan 2023 23:46:51 -0600 Subject: [PATCH] WIP --- .build/buildPsake.ps1 | 17 ++++++++++++++++- PSWriteLog/Private/Resolve-Error.ps1 | 2 +- PSWriteLog/Private/Write-Log.ps1 | 14 +++++++------- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/.build/buildPsake.ps1 b/.build/buildPsake.ps1 index 5d69bb7..9c78fb2 100644 --- a/.build/buildPsake.ps1 +++ b/.build/buildPsake.ps1 @@ -174,7 +174,7 @@ task Build -Depends BuildManifest { # } # Keep getting an error during Publish-Module. Grabbing a copy of the file from the server to see where it's erroring. - Copy-Item 'C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\PSModule.psm1' -Destination $script:parentModulePath + # Copy-Item 'C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\PSModule.psm1' -Destination ([IO.Path]::Combine($script:psScriptRootParent.FullName, 'dev')) $compress = @{ Path = [IO.Path]::Combine($script:psScriptRootParent.FullName, 'dev') @@ -411,6 +411,21 @@ task DeployPSGallery { Deployed with PSDeploy - https://github.com/RamblingCookieMonster/PSDeploy #> + + <# + PSWriteLog proxy functions are breaking PowerShellGet\PSModule.psm1 + Will dive into later if need be ... it's like just Write-Output + For now, unload them all + #> + Remove-Item 'Function:\Write-Debug' -Force -ErrorAction 'Ignore' -Verbose + Remove-Item 'Function:\Write-Error' -Force -ErrorAction 'Ignore' -Verbose + Remove-Item 'Function:\Write-Host' -Force -ErrorAction 'Ignore' -Verbose + Remove-Item 'Function:\Write-Information' -Force -ErrorAction 'Ignore' -Verbose + Remove-Item 'Function:\Write-Output' -Force -ErrorAction 'Ignore' -Verbose + Remove-Item 'Function:\Write-Progress' -Force -ErrorAction 'Ignore' -Verbose + Remove-Item 'Function:\Write-Verbose' -Force -ErrorAction 'Ignore' -Verbose + Remove-Item 'Function:\Write-Warning' -Force -ErrorAction 'Ignore' -Verbose + [IO.DirectoryInfo] $buildOutputModule = [IO.Path]::Combine($script:BuildOutput, $script:thisModuleName) Write-Host ('[PSAKE DeployPSGallery] APPVEYOR_PROJECT_NAME: {0}' -f $env:APPVEYOR_PROJECT_NAME) -Foregroundcolor 'Magenta' diff --git a/PSWriteLog/Private/Resolve-Error.ps1 b/PSWriteLog/Private/Resolve-Error.ps1 index fe56c25..821d125 100644 --- a/PSWriteLog/Private/Resolve-Error.ps1 +++ b/PSWriteLog/Private/Resolve-Error.ps1 @@ -67,7 +67,7 @@ function Resolve-Error { ## If function was called without specifying an error record, then choose the latest error that occurred if (-not $ErrorRecord) { if ($global:Error.Count -eq 0) { - Microsoft.PowerShell.Utility\Write-Information -Message 'The $Error collection is empty' -Tags 'VertigoRay\PSWriteLog','Resolve-Error' + # Microsoft.PowerShell.Utility\Write-Information -Message 'The $Error collection is empty' -Tags 'VertigoRay\PSWriteLog','Resolve-Error' return } Else { diff --git a/PSWriteLog/Private/Write-Log.ps1 b/PSWriteLog/Private/Write-Log.ps1 index e9da97e..453aed4 100644 --- a/PSWriteLog/Private/Write-Log.ps1 +++ b/PSWriteLog/Private/Write-Log.ps1 @@ -89,7 +89,7 @@ function global:Write-Log { ) begin { - Microsoft.PowerShell.Utility\Write-Information "[Write-Log] BoundParameters: $($MyInvocation.BoundParameters | Out-String)" -Tags 'VertigoRay\PSWriteLog','Write-Log' + # Microsoft.PowerShell.Utility\Write-Information "[Write-Log] BoundParameters: $($MyInvocation.BoundParameters | Out-String)" -Tags 'VertigoRay\PSWriteLog','Write-Log' # Get the name of this function [string] $CmdletName = $PSCmdlet.MyInvocation.MyCommand.Name @@ -129,7 +129,7 @@ function global:Write-Log { [string] $lMessage ) - Microsoft.PowerShell.Utility\Write-Information "[Write-Log] Source (sb): ${Source}" -Tags 'VertigoRay\PSWriteLog','Write-Log' + # Microsoft.PowerShell.Utility\Write-Information "[Write-Log] Source (sb): ${Source}" -Tags 'VertigoRay\PSWriteLog','Write-Log' $severityMap = @{ # Vaguely based on POSH stream numbers Debug = 5 Error = 3 @@ -179,7 +179,7 @@ function global:Write-Log { if (($DebugMessage -and -not $LogDebugMessage)) { Return } foreach ($msg in $Message) { - Microsoft.PowerShell.Utility\Write-Information "[Write-Log] Source: $Source" -Tags 'VertigoRay\PSWriteLog','Write-Log' + # Microsoft.PowerShell.Utility\Write-Information "[Write-Log] Source: $Source" -Tags 'VertigoRay\PSWriteLog','Write-Log' # Write the log entry to the log file if logging is not currently disabled if (-not $DisableLogging) { try { @@ -207,9 +207,9 @@ function global:Write-Log { if ($MaxLogFileSizeMB) { try { [decimal] $LogFileSizeMB = $FilePath.Length/1MB - Microsoft.PowerShell.Utility\Write-Information "[Write-Log] LogFileSizeMB: $LogFileSizeMB / $MaxLogFileSizeMB" -Tags 'VertigoRay\PSWriteLog','Write-Log' + # Microsoft.PowerShell.Utility\Write-Information "[Write-Log] LogFileSizeMB: $LogFileSizeMB / $MaxLogFileSizeMB" -Tags 'VertigoRay\PSWriteLog','Write-Log' if ($LogFileSizeMB -gt $MaxLogFileSizeMB) { - Microsoft.PowerShell.Utility\Write-Information "[Write-Log] Log File Needs to be archived ..." -Tags 'VertigoRay\PSWriteLog','Write-Log' + # Microsoft.PowerShell.Utility\Write-Information "[Write-Log] Log File Needs to be archived ..." -Tags 'VertigoRay\PSWriteLog','Write-Log' # Change the file extension to "lo_" [string] $archivedOutLogFile = [IO.Path]::ChangeExtension($FilePath.FullName, 'lo_') @@ -225,11 +225,11 @@ function global:Write-Log { # Start new log file and Log message about archiving the old log file & $getLogLine -sMsg "Maximum log file size [${MaxLogFileSizeMB} MB] reached. Previous log file was renamed to: ${archivedOutLogFile}" | Out-File -FilePath $FilePath.FullName -Append -NoClobber -Force -Encoding 'UTF8' -ErrorAction 'Stop' } else { - Microsoft.PowerShell.Utility\Write-Information "[Write-Log] Log File does not need to be archived." -Tags 'VertigoRay\PSWriteLog','Write-Log' + # Microsoft.PowerShell.Utility\Write-Information "[Write-Log] Log File does not need to be archived." -Tags 'VertigoRay\PSWriteLog','Write-Log' } } catch { # If renaming of file fails, script will continue writing to log file even if size goes over the max file size - Microsoft.PowerShell.Utility\Write-Information "[Write-Log] Archive Error: ${_}" -Tags 'VertigoRay\PSWriteLog','Write-Log' + # Microsoft.PowerShell.Utility\Write-Information "[Write-Log] Archive Error: ${_}" -Tags 'VertigoRay\PSWriteLog','Write-Log' } } }