JobRunner, JobHook: improve logging
This commit is contained in:
parent
6665d6d80f
commit
83879b5d53
|
@ -3,6 +3,7 @@
|
|||
namespace Icinga\Module\Director\Hook;
|
||||
|
||||
use Icinga\Application\Icinga;
|
||||
use Icinga\Application\Logger;
|
||||
use Icinga\Module\Director\Db;
|
||||
use Icinga\Module\Director\Objects\DirectorJob;
|
||||
use Icinga\Module\Director\Web\Form\QuickForm;
|
||||
|
@ -11,12 +12,6 @@ abstract class JobHook
|
|||
{
|
||||
private $db;
|
||||
|
||||
private $output = array();
|
||||
|
||||
private $warnings = array();
|
||||
|
||||
private $errors = array();
|
||||
|
||||
private $jobDefinition;
|
||||
|
||||
public static function getDescription(QuickForm $form)
|
||||
|
@ -84,12 +79,6 @@ abstract class JobHook
|
|||
return $this->db;
|
||||
}
|
||||
|
||||
protected function output($message)
|
||||
{
|
||||
$this->output[] = $message;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* printf helper method
|
||||
*
|
||||
|
@ -98,21 +87,21 @@ abstract class JobHook
|
|||
*
|
||||
* @return self
|
||||
*/
|
||||
protected function printf($message)
|
||||
protected function info($message)
|
||||
{
|
||||
$args = array_slice(func_get_args(), 1);
|
||||
return $this->output(vsprintf($message, $args));
|
||||
call_user_func_array(Loger::info, func_num_args());
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function warning($message)
|
||||
{
|
||||
$this->warnings[] = $message;
|
||||
call_user_func_array(Loger::warn, func_num_args());
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function error($message)
|
||||
{
|
||||
$this->errors[] = $message;
|
||||
call_user_func_array(Logger::error, func_num_args());
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,11 +101,12 @@ class ConfigJob extends JobHook
|
|||
$api->wipeInactiveStages($db);
|
||||
|
||||
$checksum = $config->getHexChecksum();
|
||||
$this->info('Director ConfigJob ready to deploy "%s"', $checksum);
|
||||
if ($api->dumpConfig($config, $db)) {
|
||||
$this->printf("Config '%s' has been deployed\n", $checksum);
|
||||
$this->info('Director ConfigJob deployed config "%s"', $checksum);
|
||||
$api->collectLogFiles($db);
|
||||
} else {
|
||||
$this->fail(sprintf("Failed to deploy config '%s'\n", $checksum));
|
||||
throw new IcingaException('Failed to deploy config "%s"', $checksum);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Icinga\Module\Director\Job;
|
||||
|
||||
use Icinga\Application\Logger;
|
||||
use Icinga\Module\Director\Db;
|
||||
use Icinga\Module\Director\Objects\DirectorJob;
|
||||
|
||||
|
@ -16,6 +17,7 @@ class JobRunner
|
|||
{
|
||||
foreach ($this->getConfiguredJobs() as $job) {
|
||||
if ($job->shouldRun()) {
|
||||
Logger::info('Director JobRunner is starting "%s"', $job->job_name);
|
||||
$this->run($job);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue