Public/Test/Test.ErrorLogs.psm1

Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop";
#Requires -Version 5.0


# INTENT: Check event viewer for app-specific errors during smoke testing
function CheckEventViewerForErrors(
    [Parameter(mandatory=$true)]
    [string] $logSource,

    [Parameter(mandatory=$true)]
    [System.DateTime] $dateGreaterThanFilter
) {
    $errorLogs = Get-EventLog -LogName Application -Source $logSource `
        | Where-Object { 
            ($_.TimeGenerated -gt $dateGreaterThanFilter) `
            -and `
            ($_.EntryType -eq 'Error')
        }
    if ($null -ne $errorLogs) {
        return false
    }
}


# INTENT: Check for error log. Presence of error log indicates a problem.
function CheckErrorLogForErrors(
    [Parameter(mandatory=$true)]
    [string] $logFilePath
) {
    if ((Test-Path -Path $logFilePath -PathType Leaf) -eq $true) {
        # TODO: Read log
        return $false;
    }
    return $true;
}


Export-ModuleMember -Function "*"