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