< Summary - Kestrun — Combined Coverage

Information
Class: Public.Logging.sinks.Add-KrSinkPowerShell
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Logging/sinks/Add-KrSinkPowerShell.ps1
Tag: Kestrun/Kestrun@9d3a582b2d63930269564a7591aa77ef297cadeb
Line coverage
0%
Covered lines: 0
Uncovered lines: 2
Coverable lines: 2
Total lines: 59
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

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Logging/sinks/Add-KrSinkPowerShell.ps1

#LineLine coverage
 1<#
 2    .SYNOPSIS
 3        Adds a PowerShell sink to the logger configuration.
 4    .DESCRIPTION
 5        The Add-KrSinkPowerShell function configures a logging sink that outputs log events to the PowerShell console. I
 6    .PARAMETER LoggerConfig
 7        The Serilog LoggerConfiguration object to which the PowerShell sink will be added.
 8    .PARAMETER RestrictedToMinimumLevel
 9        The minimum log event level required to write to the PowerShell sink. Defaults to Verbose.
 10    .PARAMETER OutputTemplate
 11        The output template string for formatting log messages. Defaults to '{Message:lj}{ErrorRecord}'.
 12    .PARAMETER LevelSwitch
 13        An optional LoggingLevelSwitch to dynamically control the logging level.
 14    .EXAMPLE
 15        Add-KrSinkPowerShell -LoggerConfig $config
 16
 17        Adds a PowerShell sink to the logging system, allowing log messages to be output to the PowerShell console.
 18    .EXAMPLE
 19        Add-KrSinkPowerShell -LoggerConfig $config -RestrictedToMinimumLevel Information
 20
 21        Adds a PowerShell sink that only outputs log events at Information level or higher.
 22    .EXAMPLE
 23        Add-KrSinkPowerShell -LoggerConfig $config -OutputTemplate '{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}]
 24        Customizes the output template for PowerShell log messages.
 25    .EXAMPLE
 26        Add-KrSinkPowerShell -LoggerConfig $config -LevelSwitch $myLevelSwitch
 27
 28        Uses a custom LoggingLevelSwitch to control the logging level dynamically.
 29    .NOTES
 30        This function is part of the Kestrun logging infrastructure and should be used to enable PowerShell console logg
 31#>
 32function Add-KrSinkPowerShell {
 33    [KestrunRuntimeApi('Everywhere')]
 34    [CmdletBinding()]
 35    [OutputType([Serilog.LoggerConfiguration])]
 36    param(
 37        [Parameter(Mandatory = $true, ValueFromPipeline = $true)]
 38        [Serilog.LoggerConfiguration]$LoggerConfig,
 39
 40        [Parameter(Mandatory = $false)]
 41        [Serilog.Events.LogEventLevel]$RestrictedToMinimumLevel = [Serilog.Events.LogEventLevel]::Verbose,
 42
 43        [Parameter(Mandatory = $false)]
 44        [string]$OutputTemplate = '{Message:lj}{ErrorRecord}',
 45
 46        [Parameter(Mandatory = $false)]
 47        [Serilog.Core.LoggingLevelSwitch]$LevelSwitch = $null
 48    )
 49
 50    process {
 051        return [Kestrun.Logging.Sinks.Extensions.PowerShellSinkExtensions]::PowerShell($LoggerConfig.WriteTo,
 052            { param([Serilog.Events.LogEvent]$logEvent, [string]$renderedMessage) Write-KrSinkPowerShell -LogEvent $logE
 53            $RestrictedToMinimumLevel,
 54            $OutputTemplate,
 55            $LevelSwitch
 56        )
 57    }
 58}
 59

Methods/Properties

Add-KrSinkPowerShell()