Public/Logging/enrichers/Add-KrEnrichErrorRecord.ps1
<# .SYNOPSIS Enriches log events with ErrorRecord property if available. .DESCRIPTION Enriches log events with ErrorRecord property if available. Use -ErrorRecord parameter on Write-*Log cmdlets to add ErrorRecord. .PARAMETER LoggerConfig Instance of LoggerConfiguration that is already setup. .PARAMETER DestructureObjects If true, and the value is a non-primitive, non-array type, then the value will be converted to a structure; otherwise, unknown types will be converted to scalars, which are generally stored as strings. .INPUTS Instance of LoggerConfiguration .OUTPUTS Instance of LoggerConfiguration .EXAMPLE PS> New-KrLogger | Add-KrEnrichErrorRecord | Add-KrSinkPowerShell | Register-KrLogger #> function Add-KrEnrichErrorRecord { [KestrunRuntimeApi('Everywhere')] [OutputType([Serilog.LoggerConfiguration])] [CmdletBinding()] param( [Parameter(Mandatory = $true, ValueFromPipeline = $true)] [Serilog.LoggerConfiguration]$LoggerConfig, [Parameter(Mandatory = $false)] [switch]$DestructureObjects ) process { return [PoShLog.Core.Enrichers.Extensions.ErrorRecordEnricherExtensions]::WithErrorRecord($LoggerConfig.Enrich, $DestructureObjects) } } |