Update logging messages and improve error handling in Start-Logging and Stop-Logging functions
This commit is contained in:
@@ -94,9 +94,9 @@ function Start-Logging {
|
||||
}
|
||||
|
||||
try {
|
||||
$LogHeader = "=== PremierOne Installation Log Started at $(Get-Date) ==="
|
||||
$LogHeader = "=== Logging Started at $(Get-Date) ==="
|
||||
Add-Content -Path $LogPath -Value $LogHeader -ErrorAction Stop
|
||||
Write-LogMessage -Message "Logging initialized" -Level Info
|
||||
Write-LogMessage -Message "Logging initialized" -Level Status
|
||||
}
|
||||
catch {
|
||||
Write-Warning "Failed to initialize logging: $_"
|
||||
@@ -108,6 +108,14 @@ function Stop-Logging {
|
||||
if ($global:loggingEnabled) {
|
||||
Write-LogMessage -Message "=== Logging stopped at $(Get-Date) ===" -Level Info
|
||||
$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: $_"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user