Add logger

This commit is contained in:
Romain Neutron
2012-05-24 15:00:21 +02:00
parent 2b7c196d13
commit 03aae8a68b

View File

@@ -9,6 +9,8 @@
* file that was distributed with this source code.
*/
use \Monolog\Logger;
/**
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
@@ -31,7 +33,7 @@ class task_manager
return $this;
}
public function getTasks($refresh = false)
public function getTasks($refresh = false, Logger $logger = null)
{
if ($this->tasks && ! $refresh) {
return $this->tasks;
@@ -39,6 +41,10 @@ class task_manager
$core = \bootstrap::getCore();
if ( ! $logger) {
$logger = $core['monolog'];
}
$sql = "SELECT task2.* FROM task2 ORDER BY task_id ASC";
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute();
@@ -55,7 +61,7 @@ class task_manager
continue;
}
try {
$tasks[$row['task_id']] = new $classname($row['task_id'], $core['monolog']);
$tasks[$row['task_id']] = new $classname($row['task_id'], $logger);
} catch (Exception $e) {
}
@@ -71,9 +77,15 @@ class task_manager
* @param int $task_id
* @return task_abstract
*/
public function getTask($task_id)
public function getTask($task_id, Logger $logger = null)
{
$tasks = $this->getTasks();
$core = \bootstrap::getCore();
if ( ! $logger) {
$logger = $core['monolog'];
}
$tasks = $this->getTasks($logger);
if ( ! isset($tasks[$task_id])) {
throw new Exception_NotFound('Unknown task_id ' . $task_id);