diff --git a/lib/classes/module/console/schedulerStart.class.php b/lib/classes/module/console/schedulerStart.class.php index 22876c6c27..cf824beccc 100644 --- a/lib/classes/module/console/schedulerStart.class.php +++ b/lib/classes/module/console/schedulerStart.class.php @@ -43,11 +43,11 @@ class module_console_schedulerStart extends Command $logger = new Logger('Task logger'); - $handler = new Handler\StreamHandler(fopen('php://stdout'), $input->getOption('verbose') ? Logger::DEBUG : Logger::WARNING); + $handler = new Handler\StreamHandler(fopen('php://stdout', 'a'), $input->getOption('verbose') ? Logger::DEBUG : Logger::WARNING); $logger->pushHandler($handler); - $logfile = __DIR__ . '/../../../../scheduler.log'; - $handler = new Handler\RotatingFileHandler($logfile, 10, $level = Logger::WARNING); + $logfile = __DIR__ . '/../../../../logs/scheduler.log'; + $handler = new Handler\RotatingFileHandler($logfile, 10); $logger->pushHandler($handler); try { diff --git a/lib/classes/module/console/taskrun.class.php b/lib/classes/module/console/taskrun.class.php index ab2169016c..4f3b7e0cab 100755 --- a/lib/classes/module/console/taskrun.class.php +++ b/lib/classes/module/console/taskrun.class.php @@ -104,8 +104,8 @@ class module_console_taskrun extends Command $logger->pushHandler($handler); } - $logfile = __DIR__ . '/../../../../task_l_' . $task_id . '.log'; - $handler = new Handler\RotatingFileHandler($logfile, 10, $level = Logger::WARNING); + $logfile = __DIR__ . '/../../../../logs/task_' . $task_id . '.log'; + $handler = new Handler\RotatingFileHandler($logfile, 10); $logger->pushHandler($handler); $this->task = $task_manager->getTask($task_id, $logger); diff --git a/lib/classes/task/Scheduler.class.php b/lib/classes/task/Scheduler.class.php index ec20693bfb..177ed370bd 100755 --- a/lib/classes/task/Scheduler.class.php +++ b/lib/classes/task/Scheduler.class.php @@ -213,27 +213,20 @@ class task_Scheduler if ( ! isset($taskPoll[$tkey])) { // the task is not in the poll, add it - $phpcli = $registry->get('GV_cli'); - switch ($system) { - case "WINDOWS": - $cmd = $phpcli; - $args = array('-f', $registry->get('GV_RootPath') . 'bin/console', '--', '-q', 'task:run', $task->getID(), '--runner=scheduler'); - break; - default: - case "DARWIN": - case "LINUX": - $cmd = $phpcli; - $args = array('-f', $registry->get('GV_RootPath') . 'bin/console', '--', '-q', 'task:run', $task->getID(), '--runner=scheduler'); - break; - } - $taskPoll[$tkey] = array( "task" => $task, "current_status" => $status, - "cmd" => $cmd, - "args" => $args, - "killat" => null, - "sigterm_sent" => false + "cmd" => $registry->get('GV_cli'), + "args" => array( + '-f', + $registry->get('GV_RootPath') . 'bin/console', + '--', + '-q', + 'task:run', + $task->getID(), '--runner=scheduler' + ), + "killat" => null, + "sigterm_sent" => false ); if ($this->method == self::METHOD_PROC_OPEN) { $taskPoll[$tkey]['process'] = NULL; diff --git a/www/admin/showlogtask.php b/www/admin/showlogtask.php index 61420e7f0d..f87530e111 100644 --- a/www/admin/showlogtask.php +++ b/www/admin/showlogtask.php @@ -8,6 +8,8 @@ * file that was distributed with this source code. */ +use Symfony\Component\Finder\Finder; + /** * * @license http://opensource.org/licenses/gpl-3.0 GPLv3 @@ -19,7 +21,7 @@ $appbox = appbox::get_instance($Core); $session = $appbox->get_session(); $request = http_request::getInstance(); -$parm = $request->get_parms('fil', 'log', 'id', 'act'); +$parm = $request->get_parms('fil', 'id', 'act'); ?> @@ -33,53 +35,49 @@ $parm = $request->get_parms('fil', 'log', 'id', 'act'); -

- logfile : - 'log', 'o' => 'stdout', 'e' => 'stderr') as $k => $v) { - $cls = ''; - if ($k == $parm['log']) - $cls = 'current'; - printf("(%s)\n" - , $cls - , urlencode($parm['fil']) - , urlencode($k) - , urlencode($parm['id']) - , $v); - } - ?> -

get_registry(); $logdir = p4string::addEndSlash($registry->get('GV_RootPath') . 'logs'); - $logfile = $logdir . $parm['fil']; - if ($parm['log']) - $logfile .= '_' . $parm['log']; - if ($parm['id']) - $logfile .= '_' . $parm['id']; - $logfile .= '.log'; - if (file_exists($logfile)) { + $name = str_replace('..', '', $parm['fil']); + + if ($parm['id']) { + $name .= '_' . $parm['id']; + } + $name .= '*.log'; + + $finder = new Finder(); + $finder + ->files()->name($name . '*') + ->in($logdir) + ->date('> now - 1 days') + ->sortByModifiedTime() + ->sort(function($a, $b) { + return -1; + }); + + $found = false; + foreach ($finder->getIterator() as $file) { if ($parm['act'] == 'CLR') { - file_put_contents($logfile, ''); + file_put_contents($file->getRealPath(), ''); - return phrasea::redirect(sprintf("/admin/showlogtask.php?fil=%s&log=%s&id=%s" + return phrasea::redirect(sprintf("/admin/showlogtask.php?fil=%s&id=%s" , urlencode($parm['fil']) - , urlencode($parm['log']) , urlencode($parm['id'])) ); } else { - printf("

%s\n", $logfile); - printf(" effacer\n" + printf("

%s\n", $file->getRealPath()); + printf(" " . _('Clear') . "" , urlencode($parm['fil']) - , urlencode($parm['log']) , urlencode($parm['id'])); print("

\n
\n");
-                print(htmlentities(file_get_contents($logfile)));
+                print(htmlentities(file_get_contents($file->getRealPath())));
                 print("
\n"); } - } else { - printf("

file %s does not exists

\n", $logfile); + $found = true; + } + if ( ! $found) { + printf("

file %s does not exists

\n", $logdir . $name); } ?>