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