mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 07:23:13 +00:00
wip
This commit is contained in:
@@ -182,26 +182,29 @@ class TaskManagerController extends Controller
|
|||||||
$factory = $this->app['task-manager.log-file.factory'];
|
$factory = $this->app['task-manager.log-file.factory'];
|
||||||
$logFile = $factory->forManager();
|
$logFile = $factory->forManager();
|
||||||
if ($request->query->get('clr')) {
|
if ($request->query->get('clr')) {
|
||||||
$logFile->clear();
|
$logFile->clear($request->query->get('version'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render('admin/task-manager/log.html.twig', [
|
return $this->render('admin/task-manager/log.html.twig', [
|
||||||
'logfile' => $logFile,
|
'logfile' => $logFile,
|
||||||
|
'version' => $request->query->get('version'),
|
||||||
'logname' => 'Scheduler',
|
'logname' => 'Scheduler',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTaskLog(Request $request, Task $task)
|
public function getTaskLog(Request $request, Task $task)
|
||||||
{
|
{
|
||||||
|
file_put_contents("/tmp/phraseanet-log.txt", sprintf("%s (%d) %s\n", __FILE__, __LINE__, var_export(null, true)), FILE_APPEND);
|
||||||
/** @var LogFileFactory $factory */
|
/** @var LogFileFactory $factory */
|
||||||
$factory = $this->app['task-manager.log-file.factory'];
|
$factory = $this->app['task-manager.log-file.factory'];
|
||||||
$logFile = $factory->forTask($task);
|
$logFile = $factory->forTask($task);
|
||||||
if ($request->query->get('clr')) {
|
if ($request->query->get('clr')) {
|
||||||
$logFile->clear();
|
$logFile->clear($request->query->get('version'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render('admin/task-manager/log.html.twig', [
|
return $this->render('admin/task-manager/log.html.twig', [
|
||||||
'logfile' => $logFile,
|
'logfile' => $logFile,
|
||||||
|
'version' => $request->query->get('version'),
|
||||||
'logname' => sprintf('%s (task id %d)', $task->getName(), $task->getId()),
|
'logname' => sprintf('%s (task id %d)', $task->getName(), $task->getId()),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@@ -34,11 +34,11 @@ abstract class AbstractLogFile implements LogFileInterface
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getContent()
|
public function getContent($version)
|
||||||
{
|
{
|
||||||
$path = $this->getPath();
|
$path = $this->getPath($version);
|
||||||
if (is_file($path)) {
|
if (is_file($path)) {
|
||||||
return file_get_contents($this->getPath());
|
return file_get_contents($this->getPath($version));
|
||||||
}
|
}
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
@@ -47,9 +47,9 @@ abstract class AbstractLogFile implements LogFileInterface
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getContentStream()
|
public function getContentStream($version)
|
||||||
{
|
{
|
||||||
$path = $this->getPath();
|
$path = $this->getPath($version);
|
||||||
|
|
||||||
return function () use ($path) {
|
return function () use ($path) {
|
||||||
$handle = fopen($path, 'r');
|
$handle = fopen($path, 'r');
|
||||||
@@ -64,8 +64,8 @@ abstract class AbstractLogFile implements LogFileInterface
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function clear($logfile)
|
public function clear($version)
|
||||||
{
|
{
|
||||||
file_put_contents($this->getPath(), '');
|
file_put_contents($this->getPath($version), '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -14,34 +14,44 @@ namespace Alchemy\Phrasea\TaskManager\Log;
|
|||||||
interface LogFileInterface
|
interface LogFileInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Returns the path to the logfile.
|
* Returns versions (suffixes due to logrotate) of the logfiles.
|
||||||
|
* ex. foo.log --> ""
|
||||||
|
* bar-2015-12-25.log --> "2015-12-25"
|
||||||
*
|
*
|
||||||
* @return string[]
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
public function getLogFiles();
|
public function getVersions();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the path of a logfile.
|
||||||
|
*
|
||||||
|
* @param string $version
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPath($version);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the content of a logfile.
|
* Returns the content of a logfile.
|
||||||
*
|
*
|
||||||
* @param string $logfile
|
* @param string $version
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getContent($logfile);
|
public function getContent($version);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Streams the content of a logfile.
|
* Streams the content of a logfile.
|
||||||
*
|
*
|
||||||
* This methods returns a closure that echoes the output.
|
* This methods returns a closure that echoes the output.
|
||||||
*
|
*
|
||||||
* @param string $logfile
|
* @param string $version
|
||||||
* @return Closure
|
* @return Closure
|
||||||
*/
|
*/
|
||||||
public function getContentStream($logfile);
|
public function getContentStream($version);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears the content of a logfile.
|
* Clears the content of a logfile.
|
||||||
*
|
*
|
||||||
* @param string $logfile
|
* @param string $version
|
||||||
*/
|
*/
|
||||||
public function clear($logfile);
|
public function clear($version);
|
||||||
}
|
}
|
||||||
|
@@ -16,8 +16,16 @@ class ManagerLogFile extends AbstractLogFile implements LogFileInterface
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getPath()
|
public function getVersions()
|
||||||
{
|
{
|
||||||
return sprintf('%s/scheduler.log', $this->root);
|
return array('');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getPath($version)
|
||||||
|
{
|
||||||
|
return sprintf('%s/scheduler%s.log', $this->root, $version ? ('-'.$version) : '' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,6 +24,14 @@ class TaskLogFile extends AbstractLogFile implements LogFileInterface
|
|||||||
$this->task = $task;
|
$this->task = $task;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getVersions()
|
||||||
|
{
|
||||||
|
return array('', '2015-12-21');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the related Task entity.
|
* Returns the related Task entity.
|
||||||
*
|
*
|
||||||
@@ -37,8 +45,8 @@ class TaskLogFile extends AbstractLogFile implements LogFileInterface
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function getPath()
|
public function getPath($version)
|
||||||
{
|
{
|
||||||
return sprintf('%s/task_%d.log', $this->root, $this->task->getId());
|
return sprintf('%s/task_%d%s.log', $this->root, $this->task->getId(), $version ? ('-'.$version) : '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,12 +1,21 @@
|
|||||||
<h4>
|
<a href="{{ path('admin_tasks_list') }} ">
|
||||||
<a href="{{ path('admin_tasks_list') }} ">
|
|
||||||
< {{ 'Return' | trans }}
|
< {{ 'Return' | trans }}
|
||||||
</a>
|
</a>
|
||||||
{{ logname }}
|
<h4>{{ logname }}</h4>
|
||||||
<a href="{{ path('admin_tasks_scheduler_log', { 'clr' : logfile.getPath() }) }} ">
|
{% for v in logfile.getVersions() %}
|
||||||
|
{% if version != null and v == version %}
|
||||||
|
<b>{{v}}]</b>
|
||||||
|
{% else %}
|
||||||
|
<a href="{{ path('admin_tasks_scheduler_log', { 'version' : v }) }}">[{{v}}]</a>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
{% if version != null %}
|
||||||
|
<a href="{{ path('admin_tasks_scheduler_log', { 'clr' : logfile.getPath(version) }) }} ">
|
||||||
{{ 'Clear' | trans }}
|
{{ 'Clear' | trans }}
|
||||||
</a>
|
</a>
|
||||||
</h4>
|
|
||||||
<pre>
|
<pre>
|
||||||
{{ logfile.getContent() }}
|
{{ logfile.getContent(version) }}
|
||||||
</pre>
|
</pre>
|
||||||
|
{% endif %}
|
||||||
|
Reference in New Issue
Block a user