mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-08 18:44:30 +00:00
Add second logging channel
This commit is contained in:
@@ -136,3 +136,4 @@ xsendfile:
|
|||||||
-
|
-
|
||||||
directory: ''
|
directory: ''
|
||||||
mount-point: ''
|
mount-point: ''
|
||||||
|
plugins: []
|
||||||
|
@@ -37,7 +37,21 @@ abstract class Command extends SymfoCommand
|
|||||||
{
|
{
|
||||||
if ($input->getOption('verbose')) {
|
if ($input->getOption('verbose')) {
|
||||||
$handler = new StreamHandler('php://stdout');
|
$handler = new StreamHandler('php://stdout');
|
||||||
$this->container['monolog']->pushHandler($handler);
|
|
||||||
|
$this->container['monolog'] = $this->container->share(
|
||||||
|
$this->container->extend('monolog', function($logger, $app) use ($handler) {
|
||||||
|
$logger->pushHandler($handler);
|
||||||
|
|
||||||
|
return $logger;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
$this->container['task-manager.logger'] = $this->container->share(
|
||||||
|
$this->container->extend('task-manager.logger', function($logger, $app) use ($handler) {
|
||||||
|
$logger->pushHandler($handler);
|
||||||
|
|
||||||
|
return $logger;
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->doExecute($input, $output);
|
return $this->doExecute($input, $output);
|
||||||
|
@@ -13,37 +13,22 @@ namespace Alchemy\Phrasea\Core\Provider;
|
|||||||
|
|
||||||
use Silex\Application;
|
use Silex\Application;
|
||||||
use Silex\ServiceProviderInterface;
|
use Silex\ServiceProviderInterface;
|
||||||
use Monolog\Handler\SyslogHandler;
|
use Monolog\Logger;
|
||||||
use Monolog\Handler\NativeMailerHandler;
|
use Monolog\Handler\NullHandler;
|
||||||
use Alchemy\Phrasea\Exception\RuntimeException;
|
|
||||||
|
|
||||||
class TaskManagerServiceProvider implements ServiceProviderInterface
|
class TaskManagerServiceProvider implements ServiceProviderInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
public function register(Application $app)
|
public function register(Application $app)
|
||||||
{
|
{
|
||||||
|
$app['task-manager.logger'] = $app->share(function(Application $app) {
|
||||||
|
$logger = new Logger('task-manager logger');
|
||||||
|
$logger->pushHandler(new NullHandler());
|
||||||
|
|
||||||
|
return $logger;
|
||||||
|
});
|
||||||
|
|
||||||
$app['task-manager'] = $app->share(function(Application $app) {
|
$app['task-manager'] = $app->share(function(Application $app) {
|
||||||
|
return new \task_manager($app, $app['task-manager.logger']);
|
||||||
$logger = clone $app['monolog'];
|
|
||||||
|
|
||||||
$options = $app['phraseanet.configuration']['main']['task-manager']['options'];
|
|
||||||
|
|
||||||
if (isset($options['syslog_level']) && null !== $syslogLevel = constant($options['syslog_level'])) {
|
|
||||||
$handler = new SyslogHandler("Phraseanet-Task", "user", $syslogLevel);
|
|
||||||
$logger->pushHandler($handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($options['maillog_level']) && null !== $maillogLevel = constant($options['maillog_level'])) {
|
|
||||||
if ('' === $adminMail = trim($app['phraseanet.registry']->get('GV_adminMail'))) {
|
|
||||||
throw new RuntimeException("Admininstrator mail must be set to get log by mail.");
|
|
||||||
}
|
|
||||||
$senderMail = $app['phraseanet.registry']->get('GV_defaultmailsenderaddr');
|
|
||||||
|
|
||||||
$handler = new NativeMailerHandler($adminMail, "Phraseanet-Task", $senderMail, $maillogLevel);
|
|
||||||
$logger->pushHandler($handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new \task_manager($app, $logger);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -18,7 +18,7 @@ namespace Alchemy\Phrasea\Core;
|
|||||||
*/
|
*/
|
||||||
class Version
|
class Version
|
||||||
{
|
{
|
||||||
protected static $number = '3.8.0.a13';
|
protected static $number = '3.8.0.a14';
|
||||||
protected static $name = 'Carnosaurus';
|
protected static $name = 'Carnosaurus';
|
||||||
|
|
||||||
public static function getNumber()
|
public static function getNumber()
|
||||||
|
@@ -96,8 +96,8 @@ class module_console_taskrun extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
$logfile = __DIR__ . '/../../../../logs/task_' . $task_id . '.log';
|
$logfile = __DIR__ . '/../../../../logs/task_' . $task_id . '.log';
|
||||||
$this->container['monolog']->pushHandler(new RotatingFileHandler($logfile, 10));
|
$this->container['task-manager.logger']->pushHandler(new RotatingFileHandler($logfile, 10));
|
||||||
$this->task = $task_manager->getTask($task_id, $this->container['monolog']);
|
$this->task = $task_manager->getTask($task_id, $this->container['task-manager.logger']);
|
||||||
|
|
||||||
$lib2v = array(
|
$lib2v = array(
|
||||||
'DEBUG' => \task_abstract::LOG_DEBUG,
|
'DEBUG' => \task_abstract::LOG_DEBUG,
|
||||||
|
57
lib/classes/patch/3814.php
Normal file
57
lib/classes/patch/3814.php
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2012 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Application;
|
||||||
|
use Entities\Session;
|
||||||
|
use Entities\SessionModule;
|
||||||
|
|
||||||
|
class patch_3814 implements patchInterface
|
||||||
|
{
|
||||||
|
/** @var string */
|
||||||
|
private $release = '3.8.0.a14';
|
||||||
|
|
||||||
|
/** @var array */
|
||||||
|
private $concern = array(base::APPLICATION_BOX);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function get_release()
|
||||||
|
{
|
||||||
|
return $this->release;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function require_all_upgrades()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function concern()
|
||||||
|
{
|
||||||
|
return $this->concern;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function apply(base $appbox, Application $app)
|
||||||
|
{
|
||||||
|
$app['phraseanet.configuration']->setDefault('plugins');
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@@ -1627,7 +1627,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
$subdefs = $databox->get_subdef_structure()->getSubdefGroup($this->get_type());
|
$subdefs = $databox->get_subdef_structure()->getSubdefGroup($this->get_type());
|
||||||
|
|
||||||
if (!$subdefs) {
|
if (!$subdefs) {
|
||||||
$app['monolog']->addInfo(sprintf('Nothing to do for %s', $this->get_type()));
|
$app['task-manager.logger']->addInfo(sprintf('Nothing to do for %s', $this->get_type()));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1644,14 +1644,14 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
if ($this->has_subdef($subdefname) && $this->get_subdef($subdefname)->is_physically_present()) {
|
if ($this->has_subdef($subdefname) && $this->get_subdef($subdefname)->is_physically_present()) {
|
||||||
$pathdest = $this->get_subdef($subdefname)->get_pathfile();
|
$pathdest = $this->get_subdef($subdefname)->get_pathfile();
|
||||||
$this->get_subdef($subdefname)->remove_file();
|
$this->get_subdef($subdefname)->remove_file();
|
||||||
$app['monolog']->addInfo(sprintf('Removed old file for %s', $subdefname));
|
$app['task-manager.logger']->addInfo(sprintf('Removed old file for %s', $subdefname));
|
||||||
$this->clearSubdefCache($subdefname);
|
$this->clearSubdefCache($subdefname);
|
||||||
}
|
}
|
||||||
|
|
||||||
$pathdest = $this->generateSubdefPathname($subdef, $app['filesystem'], $pathdest);
|
$pathdest = $this->generateSubdefPathname($subdef, $app['filesystem'], $pathdest);
|
||||||
|
|
||||||
$app['monolog']->addInfo(sprintf('Generating subdef %s to %s', $subdefname, $pathdest));
|
$app['task-manager.logger']->addInfo(sprintf('Generating subdef %s to %s', $subdefname, $pathdest));
|
||||||
$this->generate_subdef($app['media-alchemyst'], $subdef, $pathdest, $app['monolog']);
|
$this->generate_subdef($app['media-alchemyst'], $subdef, $pathdest, $app['task-manager.logger']);
|
||||||
|
|
||||||
if (file_exists($pathdest)) {
|
if (file_exists($pathdest)) {
|
||||||
$media = $app['mediavorus']->guess($pathdest);
|
$media = $app['mediavorus']->guess($pathdest);
|
||||||
|
@@ -865,7 +865,7 @@ abstract class task_abstract
|
|||||||
|
|
||||||
$tid = $dependencyContainer['phraseanet.appbox']->get_connection()->lastInsertId();
|
$tid = $dependencyContainer['phraseanet.appbox']->get_connection()->lastInsertId();
|
||||||
|
|
||||||
$task = new $class_name($tid, $dependencyContainer, $dependencyContainer['monolog']);
|
$task = new $class_name($tid, $dependencyContainer, $dependencyContainer['task-manager.logger']);
|
||||||
$task->setTitle($task->getName());
|
$task->setTitle($task->getName());
|
||||||
|
|
||||||
return $task;
|
return $task;
|
||||||
|
Reference in New Issue
Block a user