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');
|
$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);
|
$logger->pushHandler($handler);
|
||||||
|
|
||||||
$logfile = __DIR__ . '/../../../../scheduler.log';
|
$logfile = __DIR__ . '/../../../../logs/scheduler.log';
|
||||||
$handler = new Handler\RotatingFileHandler($logfile, 10, $level = Logger::WARNING);
|
$handler = new Handler\RotatingFileHandler($logfile, 10);
|
||||||
$logger->pushHandler($handler);
|
$logger->pushHandler($handler);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@@ -104,8 +104,8 @@ class module_console_taskrun extends Command
|
|||||||
$logger->pushHandler($handler);
|
$logger->pushHandler($handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
$logfile = __DIR__ . '/../../../../task_l_' . $task_id . '.log';
|
$logfile = __DIR__ . '/../../../../logs/task_' . $task_id . '.log';
|
||||||
$handler = new Handler\RotatingFileHandler($logfile, 10, $level = Logger::WARNING);
|
$handler = new Handler\RotatingFileHandler($logfile, 10);
|
||||||
$logger->pushHandler($handler);
|
$logger->pushHandler($handler);
|
||||||
|
|
||||||
$this->task = $task_manager->getTask($task_id, $logger);
|
$this->task = $task_manager->getTask($task_id, $logger);
|
||||||
|
@@ -213,27 +213,20 @@ class task_Scheduler
|
|||||||
|
|
||||||
if ( ! isset($taskPoll[$tkey])) {
|
if ( ! isset($taskPoll[$tkey])) {
|
||||||
// the task is not in the poll, add it
|
// 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(
|
$taskPoll[$tkey] = array(
|
||||||
"task" => $task,
|
"task" => $task,
|
||||||
"current_status" => $status,
|
"current_status" => $status,
|
||||||
"cmd" => $cmd,
|
"cmd" => $registry->get('GV_cli'),
|
||||||
"args" => $args,
|
"args" => array(
|
||||||
"killat" => null,
|
'-f',
|
||||||
"sigterm_sent" => false
|
$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) {
|
if ($this->method == self::METHOD_PROC_OPEN) {
|
||||||
$taskPoll[$tkey]['process'] = NULL;
|
$taskPoll[$tkey]['process'] = NULL;
|
||||||
|
@@ -8,6 +8,8 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Symfony\Component\Finder\Finder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
@@ -19,7 +21,7 @@ $appbox = appbox::get_instance($Core);
|
|||||||
$session = $appbox->get_session();
|
$session = $appbox->get_session();
|
||||||
|
|
||||||
$request = http_request::getInstance();
|
$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()); ?>">
|
<html lang="<?php echo($session->get_I18n()); ?>">
|
||||||
<head>
|
<head>
|
||||||
@@ -33,53 +35,49 @@ $parm = $request->get_parms('fil', 'log', 'id', 'act');
|
|||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<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
|
<?php
|
||||||
$registry = $appbox->get_registry();
|
$registry = $appbox->get_registry();
|
||||||
$logdir = p4string::addEndSlash($registry->get('GV_RootPath') . 'logs');
|
$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') {
|
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['fil'])
|
||||||
, urlencode($parm['log'])
|
|
||||||
, urlencode($parm['id']))
|
, urlencode($parm['id']))
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
printf("<h4>%s\n", $logfile);
|
printf("<h4>%s\n", $file->getRealPath());
|
||||||
printf(" <a href=\"/admin/showlogtask.php?fil=%s&log=%s&id=%s&act=CLR\">effacer</a>\n"
|
printf(" <a href=\"/admin/showlogtask.php?fil=%s&id=%s&act=CLR\">" . _('Clear') . "</a>"
|
||||||
, urlencode($parm['fil'])
|
, urlencode($parm['fil'])
|
||||||
, urlencode($parm['log'])
|
|
||||||
, urlencode($parm['id']));
|
, urlencode($parm['id']));
|
||||||
print("</h4>\n<pre>\n");
|
print("</h4>\n<pre>\n");
|
||||||
print(htmlentities(file_get_contents($logfile)));
|
print(htmlentities(file_get_contents($file->getRealPath())));
|
||||||
print("</pre>\n");
|
print("</pre>\n");
|
||||||
}
|
}
|
||||||
} else {
|
$found = true;
|
||||||
printf("<h4>file <b>%s</b> does not exists</h4>\n", $logfile);
|
}
|
||||||
|
if ( ! $found) {
|
||||||
|
printf("<h4>file <b>%s</b> does not exists</h4>\n", $logdir . $name);
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</body>
|
</body>
|
||||||
|
Reference in New Issue
Block a user