< Summary - Kestrun — Combined Coverage

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

#LineLine coverage
 1<#
 2    .SYNOPSIS
 3        Adds a Syslog Local sink to the Serilog logger configuration.
 4    .DESCRIPTION
 5        The Add-KrSinkSyslogLocal function configures a logging sink that sends log events to the local Syslog server.
 6        It allows customization of the application name, Syslog facility, output template, and minimum log level.
 7    .PARAMETER LoggerConfig
 8        The Serilog LoggerConfiguration object to which the Syslog Local sink will be added.
 9    .PARAMETER AppName
 10        The application name to be included in the Syslog messages. If not specified, defaults to null.
 11    .PARAMETER Facility
 12        The Syslog facility to use for the log messages. Defaults to Local0.
 13    .PARAMETER OutputTemplate
 14        The output template string for formatting log messages. Defaults to '{Message}{NewLine}{Exception}{ErrorRecord}'
 15    .PARAMETER RestrictedToMinimumLevel
 16        The minimum log event level required to write to the Syslog sink. Defaults to Verbose.
 17    .PARAMETER SeverityMapping
 18        An optional function to map Serilog log levels to Syslog severity levels.
 19    .PARAMETER Formatter
 20        An optional ITextFormatter for custom message formatting.
 21    .PARAMETER LevelSwitch
 22        An optional LoggingLevelSwitch to dynamically control the minimum log level.
 23    .EXAMPLE
 24        Add-KrSinkSyslogLocal -LoggerConfig $config -AppName "MyApp" -Facility Local1 -OutputTemplate "{Message}{NewLine
 25        Adds a Syslog Local sink to the logging system that sends log events with the specified application name, facili
 26    .EXAMPLE
 27        Add-KrSinkSyslogLocal -LoggerConfig $config
 28        Adds a Syslog Local sink to the logging system with default parameters.
 29    .EXAMPLE
 30        Add-KrSinkSyslogLocal -LoggerConfig $config -AppName "MyApp" -SeverityMapping { param($level) if ($level -eq 'Er
 31        Adds a Syslog Local sink with a custom severity mapping function.
 32    .EXAMPLE
 33        Add-KrSinkSyslogLocal -LoggerConfig $config -LevelSwitch $levelSwitch
 34        Adds a Syslog Local sink with a dynamic level switch to control the minimum log level.
 35    .NOTES
 36        This function is part of the Kestrun logging infrastructure and should be used to enable Syslog Local logging.
 37#>
 38function Add-KrSinkSyslogLocal {
 39    [KestrunRuntimeApi('Everywhere')]
 40    [CmdletBinding()]
 41    [OutputType([Serilog.LoggerConfiguration])]
 42    param(
 43        [Parameter(Mandatory = $true, ValueFromPipeline = $true)]
 44        [Serilog.LoggerConfiguration]$LoggerConfig,
 45
 46        [Parameter(Mandatory = $false)]
 47        [string]$AppName = $null,
 48
 49        [Parameter(Mandatory = $false)]
 50        [Serilog.Sinks.Syslog.Facility]$Facility = [Serilog.Sinks.Syslog.Facility]::Local0,
 51
 52        [Parameter(Mandatory = $false)]
 53        [string]$OutputTemplate,
 54
 55        [Parameter(Mandatory = $false)]
 56        [Serilog.Events.LogEventLevel]$RestrictedToMinimumLevel = [Serilog.Events.LevelAlias]::Minimum,
 57        [System.Func``2[Serilog.Events.LogEventLevel, Serilog.Sinks.Syslog.Severity]]$SeverityMapping = $null,
 58        [Serilog.Formatting.ITextFormatter]$Formatter = $null,
 59        [Serilog.Core.LoggingLevelSwitch]$LevelSwitch = $null
 60    )
 61
 62    process {
 063        return [Serilog.SyslogLoggerConfigurationExtensions]::LocalSyslog(
 64            $LoggerConfig.WriteTo,       # 1 loggerSinkConfig
 65            $AppName,                    # 2 appName
 66            $Facility,                   # 3 facility
 67            $OutputTemplate,             # 4 outputTemplate
 68            $RestrictedToMinimumLevel,   # 5 restrictedToMinimumLevel
 69            $SeverityMapping,            # 6 severityMapping
 70            $Formatter,                  # 7 formatter
 71            $LevelSwitch                 # 8 levelSwitch
 72        )
 73    }
 74}

Methods/Properties

Add-KrSinkSyslogLocal()