get('/{id}/log', function(Application $app, Request $request, $id) use ($appbox) {
$registry = $appbox->get_registry();
$logdir = \p4string::addEndSlash($registry->get('GV_RootPath') . 'logs');
$rname = '/task_' . $id . '((\.log)|(-.*\.log))$/';
$finder = new Finder();
$finder
->files()->name($rname)
->in($logdir)
// ->date('> now - 1 days')
->sortByModifiedTime();
$found = false;
foreach ($finder->getIterator() as $file) {
// printf("%s
\n", ($file->getRealPath()));
if ($request->get('clr') == $file->getFilename()) {
file_put_contents($file->getRealPath(), '');
$found = true;
}
}
if ($found) {
return $app->redirect(sprintf("/admin/task/%s/log", urlencode($id)));
}
return $app->stream(
function() use ($finder, $id) {
foreach ($finder->getIterator() as $file) {
printf("
\n"); print(htmlentities(file_get_contents($file->getRealPath()))); print("\n"); ob_flush(); flush(); } }); }); return $controllers; } }