fixed global logs

This commit is contained in:
2025-07-09 16:36:19 -04:00
parent 797840258e
commit 5d8e3263c6

View File

@@ -193,9 +193,9 @@
$Global:DattoWebhookUrl = 'https://automate.svstools.ca/webhook/svsmspkit'
# Initialize a global in-memory log cache
if (-not $Global:LogCache -or -not ($Global:LogCache -is [System.Collections.ArrayList]))
{
$Global:LogCache = [System.Collections.ArrayList]::new()
if (-not $Global:LogCache -or -not ($Global:LogCache -is [System.Collections.ArrayList])) {
$Global:LogCache = [System.Collections.ArrayList]::new()
}
#endregion global variables
@@ -312,13 +312,18 @@
Write-Host $fmt -ForegroundColor $color
# ─── In-Memory Cache ─────────────────────────────────────────────
if (-not $Global:LogCache) { $Global:LogCache = [System.Collections.ArrayList]::new() }
# ─── In-Memory Cache ─────────────────────────────────────────────
if (-not $Global:LogCache -or -not ($Global:LogCache -is [System.Collections.ArrayList])) {
$Global:LogCache = [System.Collections.ArrayList]::new()
}
$Global:LogCache.Add([pscustomobject]@{
Timestamp = (Get-Date).ToString('yyyy-MM-dd HH:mm:ss')
Level = $Level
Message = $fmt
}) | Out-Null
# ─── File Logging ────────────────────────────────────────────────
if ($PSBoundParameters.LogFile) {
try {