< Summary - Kestrun — Combined Coverage

Information
Class: Public.Logging.core.Set-KrMinimumLevel
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Logging/core/Set-KrMinimumLevel.ps1
Tag: Kestrun/Kestrun@9d3a582b2d63930269564a7591aa77ef297cadeb
Line coverage
30%
Covered lines: 3
Uncovered lines: 7
Coverable lines: 10
Total lines: 57
Line coverage: 30%
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/core/Set-KrMinimumLevel.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-KrMinimumLevel -LoggerConfig $myLoggerConfig -Value Warning
 19        Sets the minimum log level of the specified logger configuration to Warning.
 20        .EXAMPLE
 21        PS> Set-KrMinimumLevel -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-KrMinimumLevel -Value Information -PassThru
 25        Sets the minimum log level of the specified logger configuration to Information and outputs the LoggerConfigurat
 26#>
 27function Set-KrMinimumLevel {
 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        [Serilog.Events.LogEventLevel]$Value,
 37        [Parameter(Mandatory = $true, ParameterSetName = 'Dynamic')]
 38        [Serilog.Events.LogEventLevel]$Dynamic
 39    )
 40
 41    process {
 142        if ($PsCmdlet.ParameterSetName -eq 'Dynamic') {
 043            return [Kestrun.Logging.LoggerConfigurationExtensions]::EnsureSwitch($LoggerConfig, $Dynamic)
 44        } else {
 145            switch ($Value) {
 046                Verbose { return $LoggerConfig.MinimumLevel.Verbose() }
 147                Debug { return $LoggerConfig.MinimumLevel.Debug() }
 048                Information { return $LoggerConfig.MinimumLevel.Information() }
 049                Warning { return $LoggerConfig.MinimumLevel.Warning() }
 050                Error { return $LoggerConfig.MinimumLevel.Error() }
 051                Fatal { return $LoggerConfig.MinimumLevel.Fatal() }
 052                default { return $LoggerConfig.MinimumLevel.Information() }
 53            }
 54        }
 55    }
 56}
 57

Methods/Properties

Set-KrMinimumLevel()