本文整理汇总了PHP中Billrun_Factory::log方法的典型用法代码示例。如果您正苦于以下问题:PHP Billrun_Factory::log方法的具体用法?PHP Billrun_Factory::log怎么用?PHP Billrun_Factory::log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Billrun_Factory
的用法示例。
在下文中一共展示了Billrun_Factory::log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* method to execute the query
* it's called automatically by the api main controller
*/
public function execute()
{
Billrun_Factory::log()->log("Execute api query billrun", Zend_Log::INFO);
$request = $this->getRequest()->getRequest();
// supports GET / POST requests
Billrun_Factory::log()->log("Input: " . print_R($request, 1), Zend_Log::INFO);
if (!isset($request['aid'])) {
$this->setError('Require to supply aid or sid', $request);
return true;
}
$find = array();
$max_list = 1000;
if (isset($request['aid'])) {
$aids = Billrun_Util::verify_array($request['aid'], 'int');
if (count($aids) > $max_list) {
$this->setError('Maximum of aid is ' . $max_list, $request);
return true;
}
$find['aid'] = array('$in' => $aids);
}
if (isset($request['billrun'])) {
$find['billrun_key'] = $this->getBillrunQuery($request['billrun']);
}
$options = array('sort' => array('aid', 'billrun_key'));
$cacheParams = array('fetchParams' => array('options' => $options, 'find' => $find));
$this->setCacheLifeTime(604800);
// 1 week
$results = $this->cache($cacheParams);
Billrun_Factory::log()->log("query success", Zend_Log::INFO);
$ret = array(array('status' => 1, 'desc' => 'success', 'input' => $request, 'details' => $results));
$this->getController()->setOutput($ret);
}
示例2: send
/**
* method to send
*
* @param type $message
* @param type $recipients
* @return \Billrun_Sms|boolean
*/
public function send($message, $recipients)
{
if (empty($message) || empty($recipients)) {
Billrun_Factory::log()->log("can not send the sms, there are missing params - txt: " . $this->data['message'] . " recipients: " . print_r($this->data['recipients'], TRUE) . " from: " . $this->data['from'], Zend_Log::WARN);
return false;
}
$unicode_text = $this->sms_unicode($message);
if (!empty($message) && empty($unicode_text)) {
$language = '1';
} else {
$language = '2';
}
// Temporary - make sure is not 23 chars long
$text = str_pad($message, 24, '+');
$period = 120;
foreach ($recipients as $recipient) {
$send_params = array('message' => $text, 'to' => $recipient, 'from' => $this->data['from'], 'language' => $language, 'username' => $this->data['user'], 'password' => $this->data['pwd'], 'acknowledge' => "false", 'period' => $period, 'channel' => "SRV");
$url = $this->data['provisioning'] . "?" . http_build_query($send_params);
$sms_result = Billrun_Util::sendRequest($url);
$exploded = explode(',', $sms_result);
$response = array('error-code' => empty($exploded[0]) ? 'error' : 'success', 'cause-code' => $exploded[1], 'error-description' => $exploded[2], 'tid' => $exploded[3]);
Billrun_Factory::log()->log("phone: " . $recipient . " encoded_text: " . $message . " url: " . $url . " result" . print_R($response, 1), Zend_Log::INFO);
}
return $response['error-code'] == 'success' ? true : false;
}
示例3: execute
public function execute()
{
Billrun_Factory::log()->log("Execute reset", Zend_Log::INFO);
$request = $this->getRequest()->getRequest();
// supports GET / POST requests
if (empty($request['sid'])) {
return $this->setError('Please supply at least one sid', $request);
}
// remove the aids from current balance cache - on next current balance it will be recalculated and avoid to take it from cache
if (isset($request['aid'])) {
$this->cleanAccountCache($request['aid']);
}
$billrun_key = Billrun_Util::getBillrunKey(time());
// Warning: will convert half numeric strings / floats to integers
$sids = array_unique(array_diff(Billrun_Util::verify_array($request['sid'], 'int'), array(0)));
if ($sids) {
try {
$rebalance_queue = Billrun_Factory::db()->rebalance_queueCollection();
foreach ($sids as $sid) {
$rebalance_queue->insert(array('sid' => $sid, 'billrun_key' => $billrun_key, 'creation_date' => new MongoDate()));
}
} catch (Exception $exc) {
Billrun_Util::logFailedResetLines($sids, $billrun_key);
return FALSE;
}
} else {
return $this->setError('Illegal sid', $request);
}
$this->getController()->setOutput(array(array('status' => 1, 'desc' => 'success', 'input' => $request)));
return TRUE;
}
示例4: receive
/**
* General function to receive
*
* @return array list of files received
*/
public function receive()
{
Billrun_Factory::dispatcher()->trigger('beforeInlineFilesReceive', array($this));
$type = static::$type;
if (empty($this->file_content)) {
Billrun_Factory::log()->log("NOTICE : SKIPPING {$this->filename} !!! It is empty!!!", Zend_Log::NOTICE);
return FALSE;
}
$ret = array();
Billrun_Factory::log()->log("Billrun_Receiver_Inline::receive - handle file {$this->filename}", Zend_Log::DEBUG);
$this->lockFileForReceive($this->filename, $type);
$path = $this->handleFile();
if (!$path) {
Billrun_Factory::log()->log("NOTICE : Couldn't write file {$this->filename}.", Zend_Log::NOTICE);
return FALSE;
} else {
$fileData = $this->getFileLogData($this->filename, $type);
$fileData['path'] = $path;
if (!empty($this->backupPaths)) {
$backedTo = $this->backup($fileData['path'], $file->filename, $this->backupPaths, FALSE, FALSE);
Billrun_Factory::dispatcher()->trigger('beforeReceiverBackup', array($this, &$fileData['path']));
$fileData['backed_to'] = $backedTo;
Billrun_Factory::dispatcher()->trigger('afterReceiverBackup', array($this, &$fileData['path']));
}
$this->logDB($fileData);
$ret[] = $fileData['path'];
}
Billrun_Factory::dispatcher()->trigger('afterInlineFilesReceive', array($this, $ret));
return $ret;
}
示例5: calc
public function calc()
{
Billrun_Factory::log()->log("Execute reset", Zend_Log::INFO);
$rebalance_queue = Billrun_Factory::db()->rebalance_queueCollection();
$limit = Billrun_Config::getInstance()->getConfigValue('resetlines.limit', 10);
$offset = Billrun_Config::getInstance()->getConfigValue('resetlines.offset', '1 hour');
$query = array('creation_date' => array('$lt' => new MongoDate(strtotime($offset . ' ago'))));
$sort = array('creation_date' => 1);
$results = $rebalance_queue->find($query)->sort($sort)->limit($limit);
$billruns = array();
$all_sids = array();
foreach ($results as $result) {
$billruns[$result['billrun_key']][] = $result['sid'];
$all_sids[] = $result['sid'];
}
foreach ($billruns as $billrun_key => $sids) {
$model = new ResetLinesModel($sids, $billrun_key);
try {
$ret = $model->reset();
if (isset($ret['err']) && !is_null($ret['err'])) {
return FALSE;
}
$rebalance_queue->remove(array('sid' => array('$in' => $sids)));
} catch (Exception $exc) {
Billrun_Factory::log()->log('Error resetting sids ' . implode(',', $sids) . ' of billrun ' . $billrun_key . '. Error was ' . $exc->getTraceAsString(), Zend_Log::ALERT);
return $this->setError($exc->getTraceAsString(), array('sids' => $sids, 'billrun_key' => $billrun_key));
}
}
Billrun_Factory::log()->log("Success resetting sids " . implode(',', $all_sids), Zend_Log::INFO);
return true;
}
示例6: checkFilesSeq
/**
* Check the received files sequence.
* @param type $receiver
* @param type $filepaths
* @param type $hostname
* @return type
* @throws Exception
*/
protected function checkFilesSeq($filepaths, $hostname)
{
if (!isset($this->hostSequenceCheckers[$hostname])) {
throw new Exception('Couldn`t find hostname in sequence checker might be a problem with the program flow.');
}
$mailMsg = FALSE;
if ($filepaths) {
foreach ($filepaths as $path) {
$ret = $this->hostSequenceCheckers[$hostname]->addFileToSequence(basename($path));
if ($ret) {
$mailMsg .= $ret . "\n";
}
}
$ret = $this->hostSequenceCheckers[$hostname]->hasSequenceMissing();
if ($ret) {
$mailMsg .= $this->getName() . " Reciever : Received a file out of sequence from host : {$hostname} - for the following files : \n";
foreach ($ret as $file) {
$mailMsg .= $file . "\n";
}
}
} else {
if ($this->hostSequenceCheckers[$hostname]->lastLogFile) {
$timediff = time() - strtotime($this->hostSequenceCheckers[$hostname]->lastLogFile['received_time']);
if ($timediff > Billrun_Factory::config()->getConfigValue($this->getName() . '.receiver.max_missing_file_wait', 3600)) {
$mailMsg = 'Didn`t received any new ' . $this->getName() . ' files form host ' . $hostname . ' for more then ' . $timediff . ' Seconds';
}
}
}
//If there were any errors log them as high issues
if ($mailMsg) {
Billrun_Factory::log()->log($mailMsg, Zend_Log::ALERT);
}
}
示例7: execute
/**
* method to execute remove of billing lines (only credit and active)
* it's called automatically by the api main controller
*/
public function execute()
{
Billrun_Factory::log()->log("Execute api remove", Zend_Log::INFO);
$request = $this->getRequest()->getRequest();
// supports GET / POST requests
Billrun_Factory::log()->log("Input: " . print_R($request, 1), Zend_Log::INFO);
$stamps = array();
foreach ($request['stamps'] as $line_stamp) {
$clear_stamp = Billrun_Util::filter_var($line_stamp, FILTER_SANITIZE_STRING, FILTER_FLAG_ALLOW_HEX);
if (!empty($clear_stamp)) {
$stamps[] = $clear_stamp;
}
}
if (empty($stamps)) {
Billrun_Factory::log()->log("remove action failed; no correct stamps", Zend_Log::INFO);
$this->getController()->setOutput(array(array('status' => false, 'desc' => 'failed - invalid stamps input', 'input' => $request)));
return true;
}
$model = new LinesModel();
$query = array('source' => 'api', 'stamp' => array('$in' => $stamps), '$or' => array(array('billrun' => array('$gte' => Billrun_Billrun::getActiveBillrun())), array('billrun' => array('$exists' => false))));
$ret = $model->remove($query);
if (!isset($ret['ok']) || !$ret['ok'] || !isset($ret['n'])) {
Billrun_Factory::log()->log("remove action failed pr miscomplete", Zend_Log::INFO);
$this->getController()->setOutput(array(array('status' => false, 'desc' => 'remove failed', 'input' => $request)));
return true;
}
Billrun_Factory::log()->log("remove success", Zend_Log::INFO);
$this->getController()->setOutput(array(array('status' => $ret['n'], 'desc' => 'success', 'input' => $request)));
}
示例8: execute
/**
* method that outputs account, subscribers and usage of requested accounts and requested date usage
* it's called automatically by the api main controller
*/
public function execute()
{
Billrun_Factory::log()->log("Execute data triggers", Zend_Log::INFO);
$request = $this->getRequest()->getRequest();
// supports GET / POST requests
$params = array('plan', 'data_usage', 'from_account_id', 'to_account_id', 'billrun');
foreach ($params as $param) {
if (!isset($request[$param])) {
$msg = 'Missing required parameter: ' . $param;
Billrun_Factory::log()->log($msg, Zend_Log::ERR);
$this->getController()->setOutput(array(array('status' => 0, 'desc' => 'failed', 'output' => $msg)));
return;
}
}
Billrun_Factory::log()->log("Request params Received: plan-" . $request['plan'] . ", data_usage-" . $request['data_usage'] . ", from_account_id-" . $request['from_account_id'] . ", to_account_id-" . $request['to_account_id'] . ", billrun-" . $request['billrun'], Zend_Log::INFO);
$balances = new BalancesModel(array('size' => Billrun_Factory::config()->getConfigValue('balances.accounts.limit', 50000)));
$results = $balances->getBalancesVolume($request['plan'], $request['data_usage'], $request['from_account_id'], $request['to_account_id'], $request['billrun']);
if (empty($results)) {
Billrun_Factory::log()->log('Some error happen, no result, received parameters: ' . print_r($request, true), Zend_Log::ERR);
return;
}
$counter = 0;
$accounts = array();
foreach ($results as $result) {
$accounts['aid'][$result['aid']]['subs'][$result['sid']] = Billrun_Util::byteFormat($result['balance']['totals']['data']['usagev'], 'MB', 2, false, '.', '');
$counter++;
}
$this->getController()->setOutput(array(array('status' => 1, 'desc' => 'success', 'subscribers_count' => $counter, 'output' => $accounts)));
return true;
}
示例9: load
/**
* load the container the need to be generate
*/
public function load()
{
$this->data = $this->collection->aggregate($this->aggregation_array);
//TODO how to perform it on the secondaries?
Billrun_Factory::log()->log("generator entities loaded: " . count($this->data), Zend_Log::INFO);
Billrun_Factory::dispatcher()->trigger('afterGeneratorLoadData', array('generator' => $this));
}
示例10: receive
/**
* General function to receive
*
* @return array list of files received
*/
public function receive()
{
Billrun_Factory::dispatcher()->trigger('beforeLocalFilesReceive', array($this));
$type = static::$type;
if (!file_exists($this->srcPath)) {
Billrun_Factory::log()->log("NOTICE : SKIPPING {$type} !!! directory " . $this->srcPath . " not found!!", Zend_Log::NOTICE);
return array();
}
$files = $this->getFiles($this->srcPath, $this->sort, $this->order);
$ret = array();
$receivedCount = 0;
foreach ($files as $file) {
$path = $this->srcPath . DIRECTORY_SEPARATOR . $file;
if (!$this->isFileValid($file, $path) || $this->isFileReceived($file, $type) || is_dir($path)) {
Billrun_Factory::log('File ' . $file . ' is not valid or received already', Zend_Log::INFO);
continue;
}
Billrun_Factory::log()->log("Billrun_Receiver_Base_LocalFiles::receive - handle file {$file}", Zend_Log::DEBUG);
$path = $this->handleFile($path, $file);
if (!$path) {
Billrun_Factory::log()->log("NOTICE : Couldn't relocate file from {$path}.", Zend_Log::NOTICE);
continue;
}
if ($this->logDB($path) !== FALSE) {
$ret[] = $path;
if (++$receivedCount >= $this->limit) {
break;
}
}
}
Billrun_Factory::dispatcher()->trigger('afterLocalFilesReceived', array($this, $ret));
return $ret;
}
示例11: parse
/**
* @see Billrun_Processor::parse()
*/
protected function parse()
{
if (!is_resource($this->fileHandler)) {
Billrun_Factory::log()->log('Resource is not configured well', Zend_Log::ERR);
return FALSE;
}
return Billrun_Factory::chain()->trigger('processData', array($this->getType(), $this->fileHandler, &$this));
}
示例12: parse
/**
* @see Billrun_Processor::parse()
*/
protected function parse()
{
if (!is_resource($this->fileHandler)) {
Billrun_Factory::log()->log('Resource is not configured well', Zend_Log::ERR);
return FALSE;
}
$this->data['data'] = json_decode(stream_get_contents($this->fileHandler), true);
return $this->processData();
}
示例13: respondAFile
protected function respondAFile($responseFilePath, $fileName, $logLine)
{
Billrun_Factory::log()->log("Responding on : {$fileName}", Zend_Log::DEBUG);
$data = $logLine->getRawData();
$data['response_time'] = time();
$logLine->setRawData($data);
$logLine->save();
return $responseFilePath;
}
示例14: insertToQueue
protected function insertToQueue($entity)
{
$queue = Billrun_Factory::db()->queueCollection();
if (!is_object($queue)) {
Billrun_Factory::log()->log('Queue collection is not defined', Zend_Log::ALERT);
return false;
} else {
return $queue->insert(array('stamp' => $entity['stamp'], 'type' => $entity['type'], 'urt' => $entity['urt'], 'calc_name' => false, 'calc_time' => false), array('w' => 1));
}
}
示例15: execute
/**
* method to execute the query
* it's called automatically by the api main controller
*/
public function execute()
{
Billrun_Factory::log()->log("Execute api query aggregate", Zend_Log::INFO);
$request = $this->getRequest()->getRequest();
// supports GET / POST requests
Billrun_Factory::log()->log("Input: " . print_R($request, 1), Zend_Log::DEBUG);
if (!isset($request['aid']) && !isset($request['sid'])) {
$this->setError('Require to supply aid or sid', $request);
return true;
}
$find = array();
$max_list = 1000;
if (isset($request['aid'])) {
$aids = Billrun_Util::verify_array($request['aid'], 'int');
if (count($aids) > $max_list) {
$this->setError('Maximum of aid is ' . $max_list, $request);
return true;
}
$find['aid'] = array('$in' => $aids);
}
if (isset($request['sid'])) {
$sids = Billrun_Util::verify_array($request['sid'], 'int');
if (count($sids) > $max_list) {
$this->setError('Maximum of sid is ' . $max_list, $request);
return true;
}
$find['sid'] = array('$in' => $sids);
}
if (isset($request['billrun'])) {
$find['billrun'] = $this->getBillrunQuery($request['billrun']);
}
if (isset($request['query'])) {
$query = $this->getArrayParam($request['query']);
$find = array_merge($find, (array) $query);
}
if (isset($request['groupby'])) {
$groupby = array('_id' => $this->getArrayParam($request['groupby']));
} else {
$groupby = array('_id' => null);
}
if (isset($request['aggregate'])) {
$aggregate = $this->getArrayParam($request['aggregate']);
} else {
$aggregate = array('count' => array('$sum' => 1));
}
$group = array_merge($groupby, $aggregate);
$options = array('sort' => array('urt'), 'page' => isset($request['page']) && $request['page'] > 0 ? (int) $request['page'] : 0, 'size' => isset($request['size']) && $request['size'] > 0 ? (int) $request['size'] : 1000);
$cacheParams = array('fetchParams' => array('options' => $options, 'find' => $find, 'group' => $group, 'groupby' => $groupby));
$this->setCacheLifeTime(604800);
// 1 week
$results = $this->cache($cacheParams);
Billrun_Factory::log()->log("Aggregate query success", Zend_Log::INFO);
$ret = array(array('status' => 1, 'desc' => 'success', 'input' => $request, 'details' => $results));
$this->getController()->setOutput($ret);
}