< Summary - Kestrun — Combined Coverage

Information
Class: Public.Logging.core.Set-KrLoggerMinimumLevel
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Logging/core/Set-KrLoggerMinimumLevel.ps1
Tag: Kestrun/Kestrun@2d87023b37eb91155071c91dd3d6a2eeb3004705
Line coverage
0%
Covered lines: 0
Uncovered lines: 10
Coverable lines: 10
Total lines: 58
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 09/13/2025 - 17:19:56 Line coverage: 30% (3/10) Total lines: 57 Tag: Kestrun/Kestrun@ea635f1ee1937c260a89d1a43a3c203cd8767c7b10/13/2025 - 16:52:37 Line coverage: 0% (0/10) Total lines: 58 Tag: Kestrun/Kestrun@10d476bee71c71ad215bb8ab59f219887b5b4a5e

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Logging/core/Set-KrLoggerMinimumLevel.ps1

#LineLine coverage
 1<#
 2    .SYNOPSIS
 3        Sets the minimum log level for the logger configuration.
 4    .DESCRIPTION
 5        Sets the minimum log level for the logger configuration. This cmdlet can be used to
 6        set the minimum log level to a specific level or to the user's preference.
 7    .PARAMETER LoggerConfig
 8        Instance of Serilog.LoggerConfiguration to set the minimum level for.
 9    .PARAMETER Value
 10        The minimum log level to set for the logger configuration.
 11    .PARAMETER Dynamic
 12        If specified, the minimum log level will be controlled by a level switch.
 13    .INPUTS
 14        Instance of Serilog.LoggerConfiguration
 15    .OUTPUTS
 16        Instance of Serilog.LoggerConfiguration if the PassThru parameter is specified.
 17    .EXAMPLE
 18        PS> Set-KrLoggerLevel -LoggerConfig $myLoggerConfig -Values Warning
 19        Sets the minimum log level of the specified logger configuration to Warning.
 20        .EXAMPLE
 21        PS> Set-KrLoggerLevel -LoggerConfig $myLoggerConfig -ControlledBy $myLevelSwitch
 22        Sets the minimum log level of the specified logger configuration to be controlled by the specified level switch.
 23    .EXAMPLE
 24        PS> $myLoggerConfig | Set-KrLoggerLevel -Value Information -PassThru
 25        Sets the minimum log level of the specified logger configuration to Information and outputs the LoggerConfigurat
 26#>
 27function Set-KrLoggerLevel {
 28    [KestrunRuntimeApi('Everywhere')]
 29    [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '')]
 30    [OutputType([Serilog.LoggerConfiguration])]
 31    [CmdletBinding(DefaultParameterSetName = 'Static')]
 32    param(
 33        [Parameter(Mandatory = $true, ValueFromPipeline = $true)]
 34        [Serilog.LoggerConfiguration]$LoggerConfig,
 35        [Parameter(Mandatory = $true, ParameterSetName = 'Static')]
 36        [Alias('Level')]
 37        [Serilog.Events.LogEventLevel]$Value,
 38        [Parameter(Mandatory = $true, ParameterSetName = 'Dynamic')]
 39        [Serilog.Events.LogEventLevel]$Dynamic
 40    )
 41
 42    process {
 043        if ($PsCmdlet.ParameterSetName -eq 'Dynamic') {
 044            return [Kestrun.Logging.LoggerConfigurationExtensions]::EnsureSwitch($LoggerConfig, $Dynamic)
 45        } else {
 046            switch ($Value) {
 047                Verbose { return $LoggerConfig.MinimumLevel.Verbose() }
 048                Debug { return $LoggerConfig.MinimumLevel.Debug() }
 049                Information { return $LoggerConfig.MinimumLevel.Information() }
 050                Warning { return $LoggerConfig.MinimumLevel.Warning() }
 051                Error { return $LoggerConfig.MinimumLevel.Error() }
 052                Fatal { return $LoggerConfig.MinimumLevel.Fatal() }
 053                default { return $LoggerConfig.MinimumLevel.Information() }
 54            }
 55        }
 56    }
 57}
 58

Methods/Properties

Set-KrLoggerLevel()