< Summary - Kestrun — Combined Coverage

Information
Class: Public.SignalR.Send-KrSignalRLog
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/SignalR/Send-KrSignalRLog.ps1
Tag: Kestrun/Kestrun@2d87023b37eb91155071c91dd3d6a2eeb3004705
Line coverage
0%
Covered lines: 0
Uncovered lines: 5
Coverable lines: 5
Total lines: 47
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 10/15/2025 - 21:27:26 Line coverage: 0% (0/5) Total lines: 47 Tag: Kestrun/Kestrun@c33ec02a85e4f8d6061aeaab5a5e8c3a8b665594

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/SignalR/Send-KrSignalRLog.ps1

#LineLine coverage
 1<#
 2    .SYNOPSIS
 3        Broadcasts a log message to all connected SignalR clients.
 4    .DESCRIPTION
 5        This function sends a log message to all connected SignalR clients via the IRealtimeBroadcaster service.
 6        The message is broadcast in real-time to all connected clients listening on the hub.
 7    .PARAMETER Level
 8        The log level (e.g., Information, Warning, Error, Debug, Verbose).
 9    .PARAMETER Message
 10        The log message to broadcast.
 11    .EXAMPLE
 12        Send-KrSignalRLog -Level Information -Message "Server started successfully"
 13        Broadcasts an information log message to all connected SignalR clients.
 14    .EXAMPLE
 15        Send-KrSignalRLog -Level Error -Message "Failed to process request"
 16        Broadcasts an error log message to all connected SignalR clients.
 17    .EXAMPLE
 18        Get-KrServer | Send-KrSignalRLog -Level Warning -Message "High memory usage detected"
 19        Broadcasts a warning log message using the pipeline.
 20    .NOTES
 21        This function requires that SignalR has been configured on the server using Add-KrSignalRHubMiddleware.
 22        The IRealtimeBroadcaster service must be registered for this cmdlet to work.
 23#>
 24function Send-KrSignalRLog {
 25    [KestrunRuntimeApi('Everywhere')]
 26    [CmdletBinding()]
 27    param(
 28        [Parameter(Mandatory = $true)]
 29        [ValidateSet('Verbose', 'Debug', 'Information', 'Warning', 'Error', 'Fatal')]
 30        [string]$Level,
 31
 32        [Parameter(Mandatory = $true)]
 33        [string]$Message
 34    )
 35
 36    # Only works inside a route script block where $Context is available
 037    if ($null -ne $Context) {
 038        if ($Context.BroadcastLog($Level, $Message, [System.Threading.CancellationToken]::None)) {
 039            Write-KrLog -Level Debug -Message "Broadcasted log message: $Level - $Message"
 40            return
 41        } else {
 042            Write-KrLog -Level Error -Message 'Failed to broadcast log message: Unknown error'
 43            return
 44        }
 45    }
 046    Write-KrOutsideRouteWarning
 47}

Methods/Properties

Send-KrSignalRLog()