Update logging messages and improve error handling in Start-Logging and Stop-Logging functions

This commit is contained in:
2025-01-06 15:05:49 -05:00
parent 082c478fcd
commit b8753abdc9

View File

@@ -94,9 +94,9 @@ function Start-Logging {
} }
try { try {
$LogHeader = "=== PremierOne Installation Log Started at $(Get-Date) ===" $LogHeader = "=== Logging Started at $(Get-Date) ==="
Add-Content -Path $LogPath -Value $LogHeader -ErrorAction Stop Add-Content -Path $LogPath -Value $LogHeader -ErrorAction Stop
Write-LogMessage -Message "Logging initialized" -Level Info Write-LogMessage -Message "Logging initialized" -Level Status
} }
catch { catch {
Write-Warning "Failed to initialize logging: $_" Write-Warning "Failed to initialize logging: $_"
@@ -108,6 +108,14 @@ function Stop-Logging {
if ($global:loggingEnabled) { if ($global:loggingEnabled) {
Write-LogMessage -Message "=== Logging stopped at $(Get-Date) ===" -Level Info Write-LogMessage -Message "=== Logging stopped at $(Get-Date) ===" -Level Info
$global:loggingEnabled = $false $global:loggingEnabled = $false
try {
$LogHeader = "=== Logging Stopped at $(Get-Date) ==="
Add-Content -Path $LogPath -Value $LogHeader -ErrorAction Stop
Write-LogMessage -Message "Logging stopped" -Level Status
}
catch {
Write-Warning "Failed to stop logging: $_"
}
} }
} }