functions/Initialize-SimpleLog.ps1

function Initialize-SimpleLog {
    param (
        [string] $LogPath,
        [bool] $LogPrint,
        [int] $LogRetentionDays
    )
    
    if ($PSBoundParameters.ContainsKey('LogRetentionDays')) {

    }

    if (-not [string]::IsNullOrEmpty($script:LogPath)) {
        Write-SimpleLog -message "Using existing log file: $LogPat" -type INFO
    }

    $today = Get-Date
    $LogPathArray = ($LogPath -split "/")
    $DatetimeFormats = @(
        "yyyy-MM-ddTHH:mm:ss.fffZ"
        "yyyy-MM-ddTHH:mm:ssZ"
        "yyyy-MM-ddTHH:mm:ss.fff"
        "yyyy-MM-ddTHH:mm:ss"
        "yyyy-MM-dd HH:mm:ss.fff"
        "yyyy-MM-dd HH:mm:ss"
        "dd.MM.yyyy HH:mm:ss"
        "dd/MM/yyyy HH:mm:ss"
        "MM/dd/yyyy HH:mm:ss"
        "yyyy_MM_dd_HHmmss"
        "yyyyMMddHHmmss"
        "yyyy-MM-dd"
        "yyyy_MM_dd"
        "dd.MM.yyyy"
        "dd/MM/yyyy"
        "MM/dd/yyyy"
        "yyyyMMdd"
        "yyyyMM"
        "yyyy"
        "yyyy_MM_dd_hhmmii"
    )

    foreach ($DatetimeFormat in $DatetimeFormats) {
        if ($LogPathArray[-1] -like ('*{0}*' -f $DatetimeFormat)) {
            $script:LogPath = $LogPath.Replace($DatetimeFormat, $today.ToString($DatetimeFormat))
            break
        }
    }

    if ([string]::IsNullOrEmpty($script:LogPath)){
        $script:LogPath = $LogPath
    }

    $script:LogPath = [System.IO.Path]::GetFullPath([IO.Path]::Combine((Get-Location -PSProvider FileSystem).ProviderPath, $script:LogPath))
    $script:LogInitDate = $today.Date;
    $script:LogPrint = $LogPrint;

    return "Initializing log: $($script:LogPath)"
}