fixed global logs
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user