| | 1 | | <# |
| | 2 | | .SYNOPSIS |
| | 3 | | Enriches log events with ErrorRecord property if available. |
| | 4 | | .DESCRIPTION |
| | 5 | | Enriches log events with ErrorRecord property if available. Use -ErrorRecord parameter on Write-*Log cmdlets to |
| | 6 | | .PARAMETER LoggerConfig |
| | 7 | | Instance of LoggerConfiguration that is already setup. |
| | 8 | | .PARAMETER DestructureObjects |
| | 9 | | If true, and the value is a non-primitive, non-array type, then the value will be converted to a structure; othe |
| | 10 | | .INPUTS |
| | 11 | | Instance of LoggerConfiguration |
| | 12 | | .OUTPUTS |
| | 13 | | Instance of LoggerConfiguration |
| | 14 | | .EXAMPLE |
| | 15 | | PS> New-KrLogger | Add-KrEnrichErrorRecord | Add-KrSinkPowerShell | Register-KrLogger |
| | 16 | | #> |
| | 17 | | function Add-KrEnrichErrorRecord { |
| | 18 | | [KestrunRuntimeApi('Everywhere')] |
| | 19 | | [OutputType([Serilog.LoggerConfiguration])] |
| | 20 | | [CmdletBinding()] |
| | 21 | | param( |
| | 22 | | [Parameter(Mandatory = $true, ValueFromPipeline = $true)] |
| | 23 | | [Serilog.LoggerConfiguration]$LoggerConfig, |
| | 24 | | [Parameter(Mandatory = $false)] |
| | 25 | | [switch]$DestructureObjects |
| | 26 | | ) |
| | 27 | |
|
| | 28 | | process { |
| 0 | 29 | | return [PoShLog.Core.Enrichers.Extensions.ErrorRecordEnricherExtensions]::WithErrorRecord($LoggerConfig.Enrich, |
| | 30 | | } |
| | 31 | | } |
| | 32 | |
|