Updated code to use new Logging code in sihnon lib
This commit is contained in:
76
source/lib/RippingCluster/LogEntry.class.php
Normal file
76
source/lib/RippingCluster/LogEntry.class.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
class RippingCluster_LogEntry extends SihnonFramework_LogEntry {
|
||||
|
||||
protected $job_id;
|
||||
|
||||
public static function initialise() {
|
||||
self::$types['job_id'] = 'int';
|
||||
}
|
||||
|
||||
protected function __construct($level, $category, $ctime, $pid, $file, $line, $message, $job_id) {
|
||||
parent::__construct($level, $category, $ctime, $pid, $file, $line, $message);
|
||||
|
||||
$this->job_id = $job_id;
|
||||
}
|
||||
|
||||
public static function fromArray($row) {
|
||||
return new self(
|
||||
$row['level'],
|
||||
$row['category'],
|
||||
$row['ctime'],
|
||||
$row['pid'],
|
||||
$row['file'],
|
||||
$row['line'],
|
||||
$row['message'],
|
||||
$row['job_id']
|
||||
);
|
||||
}
|
||||
|
||||
public function values() {
|
||||
return array(
|
||||
$this->level,
|
||||
$this->category,
|
||||
$this->ctime,
|
||||
static::$hostname,
|
||||
static::$progname,
|
||||
$this->pid,
|
||||
$this->file,
|
||||
$this->line,
|
||||
$this->message,
|
||||
$this->job_id,
|
||||
);
|
||||
}
|
||||
|
||||
public function jobId() {
|
||||
return $this->job_id;
|
||||
}
|
||||
|
||||
protected static function log($logger, $severity, $job_id, $message, $category = SihnonFramework_Log::CATEGORY_DEFAULT) {
|
||||
$backtrace = debug_backtrace(false);
|
||||
$entry = new self($severity, $category, time(), getmypid(), $backtrace[1]['file'], $backtrace[1]['line'], $message, $job_id);
|
||||
|
||||
$logger->log($entry);
|
||||
}
|
||||
|
||||
public static function debug($logger, $job_id, $message, $category = SihnonFramework_Log::CATEGORY_DEFAULT) {
|
||||
static::log($logger, SihnonFramework_Log::LEVEL_DEBUG, $job_id, $message, $category);
|
||||
}
|
||||
|
||||
public static function info($logger, $job_id, $message, $category = SihnonFramework_Log::CATEGORY_DEFAULT) {
|
||||
static::log($logger, SihnonFramework_Log::LEVEL_INFO, $job_id, $message, $category);
|
||||
}
|
||||
|
||||
public static function warning($logger, $job_id, $message, $category = SihnonFramework_Log::CATEGORY_DEFAULT) {
|
||||
static::log($logger, SihnonFramework_Log::LEVEL_WARNING, $job_id, $message, $category);
|
||||
}
|
||||
|
||||
public static function error($logger, $job_id, $message, $category = SihnonFramework_Log::CATEGORY_DEFAULT) {
|
||||
static::log($logger, SihnonFramework_Log::LEVEL_ERROR, $job_id, $message, $category);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
RippingCluster_LogEntry::initialise();
|
||||
|
||||
?>
|
||||
@@ -16,19 +16,13 @@ class RippingCluster_Worker {
|
||||
|
||||
$config = RippingCluster_Main::instance()->config();
|
||||
|
||||
$this->gearman = new Net_Gearman_Worker('river.sihnon.net:4730');//$config->get('rips.job_servers'));
|
||||
$this->gearman = new Net_Gearman_Worker($config->get('rips.job_servers'));
|
||||
|
||||
// Load all the plugin classes
|
||||
RippingCluster_Worker_PluginFactory::scan();
|
||||
$plugins = RippingCluster_Worker_PluginFactory::getValidPlugins();
|
||||
foreach ($plugins as $plugin) {
|
||||
$this->gearman->addAbility($plugin);
|
||||
|
||||
//$workerFunctions = RippingCluster_Worker_PluginFactory::getPluginWorkerFunctions($plugin);
|
||||
//foreach ($workerFunctions as $function => $callback) {
|
||||
// echo "Added ability $function\n";
|
||||
// $this->gearman->addAbility($function);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user