diff --git a/StackMonkey.ps1 b/StackMonkey.ps1 index b02d9fb..40eb11e 100644 --- a/StackMonkey.ps1 +++ b/StackMonkey.ps1 @@ -220,25 +220,30 @@ function Write-LogHelper { } } +# ───────────────────────────────────────────────────────────────────────── +# WRITE-LOG HYBRID (single definition, chooses at runtime) +# ───────────────────────────────────────────────────────────────────────── function Write-LogHybrid { [CmdletBinding()] param( - [Parameter(Mandatory)][string]$Message, + [Parameter(Mandatory=$true)][string]$Message, [ValidateSet("Info","Warning","Error","Success","General")] [string]$Level = "Info", [string]$TaskCategory = "GeneralTask", [switch]$LogToEvent ) - # at *call* time* pick the right implementation - if ( Get-Command Write-Log -ErrorAction SilentlyContinue ) { - Write-Log @PSBoundParameters + if ( Get-Command -Name Write-Log -ErrorAction SilentlyContinue ) { + # SVSMSP module’s Write-Log is available + Write-Log -Message $Message -Level $Level -TaskCategory $TaskCategory -LogToEvent:$LogToEvent } else { - Write-LogHelper @PSBoundParameters + # fall back to your helper + Write-LogHelper -Message $Message -Level $Level -TaskCategory $TaskCategory -LogToEvent:$LogToEvent } } + #endregion # ─────────────────────────────────────────────────────────────────────────