mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-13 21:13:26 +00:00
Fix log view
This commit is contained in:
@@ -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 {
|
||||
|
@@ -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);
|
||||
|
@@ -213,25 +213,18 @@ 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,
|
||||
"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
|
||||
);
|
||||
|
@@ -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');
|
||||
?>
|
||||
<html lang="<?php echo($session->get_I18n()); ?>">
|
||||
<head>
|
||||
@@ -33,53 +35,49 @@ $parm = $request->get_parms('fil', 'log', 'id', 'act');
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>
|
||||
logfile :
|
||||
<?php
|
||||
foreach (array('l' => 'log', 'o' => 'stdout', 'e' => 'stderr') as $k => $v) {
|
||||
$cls = '';
|
||||
if ($k == $parm['log'])
|
||||
$cls = 'current';
|
||||
printf("<a class=\"%s\" href=\"/admin/showlogtask.php?fil=%s&log=%s&id=%s\">(%s)</a>\n"
|
||||
, $cls
|
||||
, urlencode($parm['fil'])
|
||||
, urlencode($k)
|
||||
, urlencode($parm['id'])
|
||||
, $v);
|
||||
}
|
||||
?>
|
||||
</h1>
|
||||
<?php
|
||||
$registry = $appbox->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("<h4>%s\n", $logfile);
|
||||
printf(" <a href=\"/admin/showlogtask.php?fil=%s&log=%s&id=%s&act=CLR\">effacer</a>\n"
|
||||
printf("<h4>%s\n", $file->getRealPath());
|
||||
printf(" <a href=\"/admin/showlogtask.php?fil=%s&id=%s&act=CLR\">" . _('Clear') . "</a>"
|
||||
, urlencode($parm['fil'])
|
||||
, urlencode($parm['log'])
|
||||
, urlencode($parm['id']));
|
||||
print("</h4>\n<pre>\n");
|
||||
print(htmlentities(file_get_contents($logfile)));
|
||||
print(htmlentities(file_get_contents($file->getRealPath())));
|
||||
print("</pre>\n");
|
||||
}
|
||||
} else {
|
||||
printf("<h4>file <b>%s</b> does not exists</h4>\n", $logfile);
|
||||
$found = true;
|
||||
}
|
||||
if ( ! $found) {
|
||||
printf("<h4>file <b>%s</b> does not exists</h4>\n", $logdir . $name);
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
|
Reference in New Issue
Block a user