diff --git a/config/configuration.sample.yml b/config/configuration.sample.yml index 2224cf8115..6ffefd4003 100644 --- a/config/configuration.sample.yml +++ b/config/configuration.sample.yml @@ -26,6 +26,11 @@ main: search-engine: type: Alchemy\Phrasea\SearchEngine\Phrasea\PhraseaEngine options: [] + task-manager: + logger: + max-files: 10 + enabled: true + level: INFO binaries: ghostscript_binary: null php_binary: null diff --git a/lib/classes/module/console/schedulerStart.php b/lib/classes/module/console/schedulerStart.php index c0c90a0288..e030444cfa 100644 --- a/lib/classes/module/console/schedulerStart.php +++ b/lib/classes/module/console/schedulerStart.php @@ -41,9 +41,21 @@ class module_console_schedulerStart extends Command $streamHandler = new Handler\StreamHandler('php://stdout', $input->getOption('verbose') ? Logger::DEBUG : Logger::WARNING); $logger->pushHandler($streamHandler); - $logfile = __DIR__ . '/../../../../logs/scheduler.log'; - $rotateHandler = new Handler\RotatingFileHandler($logfile, 10, Logger::INFO); - $logger->pushHandler($rotateHandler); + $taskManagerConf = isset($this->container['phraseanet.configuration']['main']['task-manager']) ? $this->container['phraseanet.configuration']['main']['task-manager'] : array(); + $taskManagerConf = array_replace_recursive(array( + 'logger' => array( + 'enabled' => true, + 'level' => 'INFO', + 'max-files' => 10, + ) + ), $taskManagerConf); + + if ($taskManagerConf['logger']['enabled']) { + $level = defined('Monolog\\Logger::'.$taskManagerConf['logger']['level']) ? constant('Monolog\\Logger::'.$taskManagerConf['logger']['level']) : Logger::INFO; + $logfile = __DIR__ . '/../../../../logs/scheduler.log'; + $rotateHandler = new Handler\RotatingFileHandler($logfile, $taskManagerConf['logger']['max-files'], $level); + $logger->pushHandler($rotateHandler); + } try { $scheduler = new task_Scheduler($this->container, $logger); diff --git a/lib/classes/module/console/taskrun.php b/lib/classes/module/console/taskrun.php index a78ff818c0..3b30ad7f5c 100644 --- a/lib/classes/module/console/taskrun.php +++ b/lib/classes/module/console/taskrun.php @@ -96,8 +96,21 @@ class module_console_taskrun extends Command } } - $logfile = __DIR__ . '/../../../../logs/task_' . $task_id . '.log'; - $this->container['task-manager.logger']->pushHandler(new RotatingFileHandler($logfile, 10, Logger::INFO)); + $taskManagerConf = isset($this->container['phraseanet.configuration']['main']['task-manager']) ? $this->container['phraseanet.configuration']['main']['task-manager'] : array(); + $taskManagerConf = array_replace_recursive(array( + 'logger' => array( + 'enabled' => true, + 'level' => 'INFO', + 'max-files' => 10, + ) + ), $taskManagerConf); + + if ($taskManagerConf['logger']['enabled']) { + $level = defined('Monolog\\Logger::'.$taskManagerConf['logger']['level']) ? constant('Monolog\\Logger::'.$taskManagerConf['logger']['level']) : Logger::INFO; + $logfile = __DIR__ . '/../../../../logs/task_' . $task_id . '.log'; + $this->container['task-manager.logger']->pushHandler(new RotatingFileHandler($logfile, $taskManagerConf['logger']['max-files'], $level)); + } + $this->task = $task_manager->getTask($task_id, $this->container['task-manager.logger']); $lib2v = array( diff --git a/lib/classes/patch/383alpha5a.php b/lib/classes/patch/383alpha5a.php new file mode 100644 index 0000000000..623fa05266 --- /dev/null +++ b/lib/classes/patch/383alpha5a.php @@ -0,0 +1,63 @@ +release; + } + + /** + * {@inheritdoc} + */ + public function require_all_upgrades() + { + return false; + } + + /** + * {@inheritdoc} + */ + public function concern() + { + return $this->concern; + } + + /** + * {@inheritdoc} + */ + public function apply(base $appbox, Application $app) + { + $config = $app['phraseanet.configuration']->getConfig(); + + $config['main']['task-manager']['logger'] = array( + 'enabled' => true, + 'max-files' => 10, + 'level' => 'INFO', + ); + + $app['phraseanet.configuration']->setConfig($config); + + return true; + } +} diff --git a/lib/conf.d/configuration.yml b/lib/conf.d/configuration.yml index 8ebfa9f96a..174ae96d36 100644 --- a/lib/conf.d/configuration.yml +++ b/lib/conf.d/configuration.yml @@ -26,6 +26,11 @@ main: search-engine: type: Alchemy\Phrasea\SearchEngine\Phrasea\PhraseaEngine options: [] + task-manager: + logger: + max-files: 10 + enabled: true + level: INFO trusted-proxies: [] debugger: allowed-ips: []