< Summary - Kestrun — Combined Coverage

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

#LineLine coverage
 1<#
 2    .SYNOPSIS
 3        Sets the minimum logging level for a level switch.
 4    .DESCRIPTION
 5        Sets the minimum logging level for a specified level switch. If ToPreference is specified,
 6        the logging level will be set to the user's preference.
 7    .PARAMETER Logger
 8        An instance of Serilog.Core.Logger to set the level switch for.
 9        It's mutually exclusive with the LoggerName parameter.
 10    .PARAMETER LoggerName
 11        The name of a registered logger to set the level switch for.
 12        It's mutually exclusive with the Logger parameter.
 13    .PARAMETER MinimumLevel
 14        The minimum logging level to set for the switch.
 15    .EXAMPLE
 16        PS> Set-KrLevelSwitch -LoggerName "MyLogger" -MinimumLevel Warning
 17        Sets the minimum logging level of the level switch for the logger named "MyLogger" to Warning.
 18    .EXAMPLE
 19        PS> Set-KrLevelSwitch -Logger $myLogger -MinimumLevel Error
 20        Sets the minimum logging level of the level switch for the specified logger instance to Error.
 21#>
 22function Set-KrLevelSwitch {
 23    [KestrunRuntimeApi('Everywhere')]
 24    [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '')]
 25    [CmdletBinding(DefaultParameterSetName = 'LoggerName')]
 26    param(
 27        [Parameter(Mandatory = $false, ParameterSetName = 'LoggerName')]
 28        [string]$LoggerName,
 29        [Parameter(Mandatory = $true, ParameterSetName = 'Logger')]
 30        [Serilog.Core.Logger]$Logger,
 31        [Parameter(Mandatory = $true)]
 32        [Serilog.Events.LogEventLevel]$MinimumLevel
 33    )
 34
 035    if ([string]::IsNullOrEmpty($LoggerName)) {
 036        $LoggerName = [Kestrun.Logging.LoggerManager]::GetName($Logger)
 37    }
 038    if ([string]::IsNullOrEmpty($LoggerName)) {
 039        throw [System.ArgumentException]::new("LoggerName cannot be null or empty.")
 40    }
 041    [Kestrun.Logging.LoggerManager]::SetLevelSwitch($LoggerName, $MinimumLevel)
 42}
 43

Methods/Properties

Set-KrLevelSwitch()