Update StackMonkey.ps1

This commit is contained in:
2025-06-25 00:20:23 -04:00
parent 57400ac8ff
commit 51fd370f9d

View File

@@ -120,6 +120,13 @@ function Get-DattoApiCredentials {
} }
} }
#region Logging Helpers
# 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()
}
# Core Write-Log function (advanced with event-log support) # Core Write-Log function (advanced with event-log support)
function Write-LogHelper { function Write-LogHelper {
[CmdletBinding()] [CmdletBinding()]
@@ -158,6 +165,15 @@ function Write-LogHelper {
} }
} }
# Hybrid wrapper: uses your module's Write-Log if available, else falls back
if (Get-Command Write-Log -ErrorAction SilentlyContinue) {
function Write-LogHybrid { param($Message,$Level,$TaskCategory,$LogToEvent) Write-Log @PSBoundParameters }
} else {
function Write-LogHybrid { param($Message,$Level,$TaskCategory,$LogToEvent) Write-LogHelper @PSBoundParameters }
}
#endregion
# ───────────────────────────────────────────────────────────────────────── # ─────────────────────────────────────────────────────────────────────────
# 3) MAIN LOGIC (Toolkit vs Datto vs UI) # 3) MAIN LOGIC (Toolkit vs Datto vs UI)
# ───────────────────────────────────────────────────────────────────────── # ─────────────────────────────────────────────────────────────────────────
@@ -262,24 +278,6 @@ $Global:Tasks = @(
#endregion #endregion
#region Logging Helpers
# 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()
}
# Hybrid wrapper: uses your module's Write-Log if available, else falls back
if (Get-Command Write-Log -ErrorAction SilentlyContinue) {
function Write-LogHybrid { param($Message,$Level,$TaskCategory,$LogToEvent) Write-Log @PSBoundParameters }
} else {
function Write-LogHybrid { param($Message,$Level,$TaskCategory,$LogToEvent) Write-LogHelper @PSBoundParameters }
}
#endregion
# If we got here, it's the UI set—launch browser + listener: # If we got here, it's the UI set—launch browser + listener:
# ——— UI fallback starts here ——— # ——— UI fallback starts here ———