Private/Write-LogLine.ps1
|
# Internal helper -- logs to stdout AND appends to a log file with timestamp + level. # Renamed from `Log` (start-channels.ps1) to comply with PowerShell approved-verb policy. function Write-LogLine { param( [Parameter(Mandatory)][ValidateNotNullOrEmpty()][string]$Message, [Parameter(Mandatory)][ValidateNotNullOrEmpty()][string]$Level, [Parameter(Mandatory)][ValidateNotNullOrEmpty()][string]$LogFile ) $ts = Get-Date -Format 'yyyy-MM-ddTHH:mm:ss' $line = "[$ts] [$Level] $Message" Write-Host $line # -LiteralPath instead of -FilePath ([G4] security F4): wildcard # characters [ ] in $LogFile would otherwise trigger PowerShell glob # expansion and write to an unexpected location. $line | Out-File -LiteralPath $LogFile -Append -Encoding utf8 } |