| | 1 | | <# |
| | 2 | | .SYNOPSIS |
| | 3 | | Gets the logger for the current session. |
| | 4 | | .DESCRIPTION |
| | 5 | | Gets the specified logger as the current logger for the session. |
| | 6 | | .PARAMETER Name |
| | 7 | | The name of the logger to get as the default logger. |
| | 8 | | .OUTPUTS |
| | 9 | | Returns the current default logger instance for the session. |
| | 10 | | When the Name parameter is specified, it returns the name of the default logger. |
| | 11 | | When the Name parameter is not specified, it returns the default logger instance. |
| | 12 | | .EXAMPLE |
| | 13 | | PS> $logger = Get-KrDefaultLogger |
| | 14 | | Retrieves the current default logger instance for the session. |
| | 15 | | .EXAMPLE |
| | 16 | | PS> $logger = Get-KrDefaultLogger | Write-Host |
| | 17 | | Retrieves the current default logger instance and outputs it to the console. |
| | 18 | | .NOTES |
| | 19 | | This function is part of the Kestrun logging framework and is used to retrieve the current default logger instan |
| | 20 | | It can be used in scripts and modules that utilize Kestrun for logging. |
| | 21 | | #> |
| | 22 | | function Get-KrDefaultLogger { |
| | 23 | | [KestrunRuntimeApi('Everywhere')] |
| | 24 | | [CmdletBinding()] |
| | 25 | | [OutputType([Serilog.ILogger])] |
| | 26 | | [OutputType([string])] |
| | 27 | | param( |
| | 28 | | [Parameter(Mandatory = $false)] |
| | 29 | | [switch]$Name |
| | 30 | | ) |
| 0 | 31 | | if ($Name) { |
| 0 | 32 | | return [Kestrun.Logging.LoggerManager]::DefaultLoggerName |
| | 33 | | } |
| 0 | 34 | | return [Kestrun.Logging.LoggerManager]::DefaultLogger |
| | 35 | | } |
| | 36 | |
|