Public/ps1/Log/Get-ApprxrLog.ps1
|
<##
.SYNOPSIS Retrieves log file contents for the Apprxr module. .DESCRIPTION Reads the log file specified in $LogManagement.LogFolder. If -watching is used, streams new log entries as they are written (file watcher mode). .PARAMETER watching If specified, enables real-time log monitoring using Get-Content -Wait. .EXAMPLE Get-ApprxrLog Returns the current contents of the log file. .EXAMPLE Get-ApprxrLog -watching Continuously outputs new log entries as they are written (file watcher mode). ##> function Get-ApprxrLog { param( [switch]$watching, # Enables real-time log monitoring if specified [int]$Tail = 100 # Number of lines to show, default is 100 ) # Ensure $LogManagement is available and not null if ($LogManagement -ne $null){ $logFile = $LogManagement.LogFolder # Path to the log file if ($watching) { # File watcher: stream new log entries as they are written, starting with the last $Tail lines Get-Content $logFile -Wait -Tail $Tail } else { # Output only the last $Tail lines of the log file Get-Content $logFile -Tail $Tail } } } |