Public/ps1/Configuration/Logging/Install-ApprxrLogging.ps1

<#
.SYNOPSIS
    Initializes the Apprxr log configuration by creating the configuration file with default or provided settings.
.DESCRIPTION
    Uses Set-LogConfiguration to create and store the log configuration file. If parameters are not provided, defaults are used.
.PARAMETER LogFolder
    The folder path for log storage. Default is 'C:\Logs'.
.PARAMETER LogHours
    The number of hours to retain logs. Default is 24.
.PARAMETER LogRetention
    The number of log files to retain. Default is 7.
.EXAMPLE
    Install-ApprxrLogging -LogFolder 'C:\Logs' -LogHours 24 -LogRetention 7
#>

function Install-ApprxrLogging {
    [CmdletBinding()]
    param(
        [int]$LogHours = 24,
        [int]$LogRetention = 7
    )
    
    $logConfigExists = $false
    try {
        $logConfig = Load-ApprxrLogConfiguration
        if ($logConfig -and $logConfig.LogFolder -and (Test-Path $logConfig.LogFolder)) {
            $logConfigExists = $true
        }
    } catch {
        $logConfigExists = $false
    }

    if ($logConfigExists) {
        Write-Host "Log configuration already exists and is working at $($logConfig.LogFolder)."
        return $logConfig
    } else {
        Set-ApprxrLogConfiguration -LogHours $LogHours -LogRetention $LogRetention
        Write-Host "Log configuration initialized with retention $LogRetention files for $LogHours hours."
        return Load-ApprxrLogConfiguration
    }
}