< Summary - Kestrun — Combined Coverage

Information
Class: Public.Logging.core.Register-KrLogger
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Logging/core/Register-KrLogger.ps1
Tag: Kestrun/Kestrun@0d738bf294e6281b936d031e1979d928007495ff
Line coverage
0%
Covered lines: 0
Uncovered lines: 3
Coverable lines: 3
Total lines: 63
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 08/26/2025 - 14:53:17 Line coverage: 36.3% (4/11) Total lines: 95 Tag: Kestrun/Kestrun@78d1e497d8ba989d121b57aa39aa3c6b22de743109/04/2025 - 18:11:31 Line coverage: 36.3% (4/11) Total lines: 96 Tag: Kestrun/Kestrun@de99e24698289f3f61ac7b73e96092732ae12b0509/07/2025 - 04:51:39 Line coverage: 100% (3/3) Total lines: 63 Tag: Kestrun/Kestrun@461ff737fcae3442df54fb34b135b2349f239c4f10/13/2025 - 16:52:37 Line coverage: 0% (0/3) Total lines: 63 Tag: Kestrun/Kestrun@10d476bee71c71ad215bb8ab59f219887b5b4a5e

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Logging/core/Register-KrLogger.ps1

#LineLine coverage
 1<#
 2    .SYNOPSIS
 3        Starts the Kestrun logger.
 4    .DESCRIPTION
 5        This function initializes the Kestrun logger with specified configurations.
 6    .PARAMETER Name
 7        The name of the logger instance. This is mandatory.
 8    .PARAMETER LoggerConfig
 9        A Serilog logger configuration object to set up the logger.
 10    .PARAMETER MinimumLevel
 11        The minimum log level for the logger. Default is Information.
 12    .PARAMETER Console
 13        If specified, adds a console sink to the logger.
 14    .PARAMETER PowerShell
 15        If specified, adds a PowerShell sink to the logger.
 16    .PARAMETER FilePath
 17        The file path where logs will be written. If not specified, defaults to a predefined path
 18    .PARAMETER FileRollingInterval
 19        The rolling interval for the log file. Default is Infinite.
 20    .PARAMETER SetAsDefault
 21        If specified, sets the created logger as the default logger for Serilog.
 22    .PARAMETER PassThru
 23        If specified, returns the created logger object.
 24    .EXAMPLE
 25        Register-KrLogger -Name "MyLogger" -MinimumLevel Debug -Console -FilePath "C:\Logs\kestrun.log" -FileRollingInte
 26        Initializes the Kestrun logger with Debug level, adds console and file sinks, sets the logger as default, and re
 27    .EXAMPLE
 28        Register-KrLogger -Name "MyLogger" -LoggerConfig $myLoggerConfig -SetAsDefault
 29        Initializes the Kestrun logger using a pre-configured Serilog logger configuration object and sets it as the def
 30    .EXAMPLE
 31        Register-KrLogger -Name "MyLogger" -MinimumLevel Debug -Console -FilePath "C:\Logs\kestrun.log" -FileRollingInte
 32        Initializes the Kestrun logger with Debug level, adds console and file sinks, sets the logger as default, and re
 33    .EXAMPLE
 34        Register-KrLogger -Name "MyLogger" -MinimumLevel Debug -Console -FilePath "C:\Logs\kestrun.log" -FileRollingInte
 35        Initializes the Kestrun logger with Debug level, adds console and file sinks, sets the logger as default, and re
 36#>
 37function Register-KrLogger {
 38    [KestrunRuntimeApi('Everywhere')]
 39    [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '')]
 40    [CmdletBinding()]
 41    [OutputType([Serilog.ILogger])]
 42    param(
 43        [Parameter(Mandatory = $true)]
 44        [string]$Name,
 45
 46        [Parameter(Mandatory = $true, ValueFromPipeline = $true)]
 47        [Serilog.LoggerConfiguration]$LoggerConfig,
 48
 49        [Parameter(Mandatory = $false)]
 50        [switch]$SetAsDefault,
 51
 52        [Parameter(Mandatory = $false)]
 53        [switch]$PassThru
 54    )
 55
 56    process {
 057        $logger = [Kestrun.Logging.LoggerConfigurationExtensions]::Register($LoggerConfig, $Name, $SetAsDefault.IsPresen
 058        if ($PassThru) {
 059            return $logger
 60        }
 61    }
 62}
 63

Methods/Properties

Register-KrLogger()