コード例 #1
0
/**
 * @param TestPaths $localPaths The paths for the run or step to get the console log for
 * @return array|null The console log or null, if it couldn't be retrieved
 */
function DevToolsGetConsoleLogForStep($localPaths)
{
    $console_log = null;
    $console_log_file = $localPaths->consoleLogFile();
    if (gz_is_file($console_log_file)) {
        $console_log = json_decode(gz_file_get_contents($console_log_file), true);
    } elseif (gz_is_file($localPaths->devtoolsFile())) {
        $console_log = array();
        $startOffset = null;
        if (GetDevToolsEventsForStep('Console.messageAdded', $localPaths, $events, $startOffset) && is_array($events) && count($events)) {
            foreach ($events as $event) {
                if (is_array($event) && array_key_exists('message', $event) && is_array($event['message'])) {
                    $console_log[] = $event['message'];
                }
            }
        }
        gz_file_put_contents($console_log_file, json_encode($console_log));
    }
    return $console_log;
}