public function testGetLogs() { $logger = new CLogger(); $logs = array(array('message1', 'debug', 'application.pages'), array('message2', 'info', 'application.config'), array('message3', 'info', 'application.pages')); foreach ($logs as $log) { $logger->log($log[0], $log[1], $log[2]); } $l = $logger->getLogs('debug'); $this->assertTrue($logs[0] === array_slice($l[0], 0, 3)); $l = $logger->getLogs('debug , Info'); $this->assertTrue($logs[0] === array_slice($l[0], 0, 3)); $this->assertTrue($logs[1] === array_slice($l[1], 0, 3)); $this->assertTrue($logs[2] === array_slice($l[2], 0, 3)); $l = $logger->getLogs('', 'application.config'); $this->assertTrue($logs[1] === array_slice($l[0], 0, 3)); $l = $logger->getLogs('', 'application.*'); $this->assertTrue($logs[0] === array_slice($l[0], 0, 3)); $this->assertTrue($logs[1] === array_slice($l[1], 0, 3)); $this->assertTrue($logs[2] === array_slice($l[2], 0, 3)); $l = $logger->getLogs('', 'application.config , Application.pages'); $this->assertTrue($logs[0] === array_slice($l[0], 0, 3)); $this->assertTrue($logs[1] === array_slice($l[1], 0, 3)); $this->assertTrue($logs[2] === array_slice($l[2], 0, 3)); $l = $logger->getLogs('info', 'application.config'); $this->assertTrue($logs[1] === array_slice($l[0], 0, 3)); $l = $logger->getLogs('info,debug', 'application.config'); $this->assertTrue($logs[1] === array_slice($l[0], 0, 3)); }
/** * Retrieves filtered log messages from logger for further processing. * @param CLogger $logger logger instance * @param boolean $processLogs whether to process the logs after they are collected from the logger */ public function collectLogs($logger, $processLogs = false) { $logs = $logger->getLogs($this->levels, $this->categories); $this->logs = empty($this->logs) ? $logs : array_merge($this->logs, $logs); if ($processLogs && !empty($this->logs)) { if ($this->filter !== null) { Yii::createComponent($this->filter)->filter($this->logs); } $this->processLogs($this->logs); $this->logs = array(); } }
/** * Test * * @return void * */ public function testWriteErrors() { CLogger::init(); $res = CLogger::writeErrors(E_WARNING, "Test", "Test.php", 1); $exp = true; $this->assertEquals($res, $exp, "Created element name missmatch."); }
public static function getInstance() { if (is_null(self::$instance)) { self::$instance = new self(); } return self::$instance; }
private function _createPaymentURL(PayPal\Api\Payer $payer, PayPal\Api\RedirectUrls $redirectUrls, PayPal\Api\Transaction $transaction, PayPal\Rest\ApiContext $apiContext) { $payment = new PayPal\Api\Payment(); $payment->setIntent("sale")->setPayer($payer)->setRedirectUrls($redirectUrls)->setTransactions(array($transaction)); try { $payment->create($apiContext); } catch (Exception $e) { CLogger::getInstance()->add(__LINE__, __METHOD__, 'exception error', $e); die; } $url = $payment->getApprovalLink(); CLogger::getInstance()->add(__LINE__, __METHOD__, 'url paypal', $url); CLogger::getInstance()->getLog('PayPal starting checkout'); header("Location: {$url}"); exit; }
<?php require_once 'app/includes/header.inc.php'; $result = CProcess::getInstance()->process($settings['billing']['paypal']); CLogger::getInstance()->getLog('PayPal Billing Result');
/** * Sets the date format used by all instances of CLogger * * @param string $dateFormat Valid format string for date() */ public static function setDateFormat($dateFormat) { self::$_dateFormat = $dateFormat; }
private static function _process(\PayPal\Api\Payment &$payment, PayPal\Rest\ApiContext &$apiContext, PayPal\Api\PaymentExecution &$execution) { #Logger CLogger::getInstance()->add(__LINE__, __CLASS__, 'status_before_to_process', self::_getStatus($payment)); try { $result = $payment->execute($execution, $apiContext); CLogger::getInstance()->add(__LINE__, __CLASS__, 'result', $result); $payment_success = true; } catch (Exception $e) { $data = json_decode($e->getData()); $payment_success = array('code' => $e->getCode(), 'message' => $e->getMessage(), 'line' => $e->getLine(), 'file' => $e->getFile(), 'exception' => $data->name, 'reason' => self::_getFailureReason($payment)); } #Logger CLogger::getInstance()->add(__LINE__, __CLASS__, 'payment_status', $payment_success); CLogger::getInstance()->add(__LINE__, __CLASS__, 'status_after_to_process', self::_getStatus($payment)); return $payment_success; }
</div><!-- End #sidebar --> <?php } ?> </div><!-- End #content --> <div id="footer"> <ul> <li><?php echo Yii::t('global', 'Powered By {x}', array('{x}' => CHtml::link('X', '#'))); ?> </li> <li class="alignright"><?php echo Yii::t('global', 'Page generated in {time} seconds', array('{time}' => round(CLogger::getExecutionTime(), 3))); ?> </li> </ul> </div> </div><!-- End #container --> <?php $settings = array('baseUrl' => Yii::app()->baseUrl, 'currentUrl' => $this->createUrl(''), 'debugMode' => (int) YII_DEBUG); $phrases = array_merge($this->jsLanguages, array('cancel' => Yii::t('global', 'Cancel'), 'deleteConfirm' => Yii::t('global', 'Are you sure you would like to delete this item?'), 'inlineEditButton' => Yii::t('global', 'Update'))); $phrases = 'Tracker.phrases = ' . CJSON::encode($phrases) . ';'; $settings = 'Tracker.settings = ' . CJSON::encode($settings) . ';'; Yii::app()->clientScript->registerScript('_sitesettings', $settings, CClientScript::POS_END); Yii::app()->clientScript->registerScript('_sitephrases', $phrases, CClientScript::POS_END); ?> </body>
public static function setLogId($intLogId) { CLogger::getInstance()->intLogId = $intLogId; }
function dc_report_modulelog($mid, $sid, $ifid, $mip, $sip, $retval, $result, $delay) { $config = getConf('ROUTE.DCREPORT'); if ($config['REPORTSWITCH'] == 0) { dc_log(ERROR, EC_OK, 'dc_report_modulelog error, ROUTE.DCREPORT[REPORTSWITCH] is off'); return; } $clogger = new CLogger(); $ret = $clogger->init_mod($mid); if ($ret != 0) { dc_log(ERROR, EC_OK, 'dc_report_modulelog error, ret=' . $ret); return -1; } //int sid, int ifid, string& mip, string& sip, int retval, int result, int delay ,intres1,intres2,strres1,strres2 $ret = $clogger->write_modulelog($sid, $ifid, $mip, $sip, $retval, $result, $delay, 0, 0, "", ""); if ($ret != 0) { dc_log(ERROR, EC_OK, 'dc_report_modulelog error, ' . $clogger->get_errmsg()); return -2; } return 0; }
<?php ini_set("display_errors", true); require_once dirname(__FILE__) . "/../CLogger.Class.php"; while (1) { CLogger::warning("this is warning."); sleep(1); CLogger::notice("this is notice."); sleep(1); CLogger::debug("this is debug."); sleep(1); }
echo ' '.CHtml::link('<span class="add-button">'.Yii::t('app','Action').'</span>',array('actions/create','param'=>Yii::app()->user->getName().';none:0'),array('class'=>'x2-button'))." \n"; echo ' '.CHtml::link('<span class="add-button">'.Yii::t('app','Contact + Action').'</span>',array('actions/quickCreate'),array('class'=>'x2-button'))." \n"; ?> </div> <?php } echo $content; ?> <div id="footer"> <hr><div id="footer-logos"> <?php $imghtml = CHtml::image($themeURL.'/images/x2footer.png',''); echo CHtml::link($imghtml,array('site/page','view'=>'about')); // Yii::app()->request->baseURL.'/index.php'); ?></div> Copyright © <?php echo date('Y').' '.CHtml::link('X2Engine Inc.','http://www.x2engine.com');?> <?php echo Yii::t('app','Rights reservered.'); ?> <?php echo Yii::t('app','The Program is provided AS IS, without warranty.<br />Licensed under {GPLv3}. This program is free software; you can redistribute it and/or modify it<br />under the terms of the {GPLv3long} as published by the Free Software Foundation<br />including the additional permission set forth in the source code header.', array( '{GPLv3}'=>CHtml::link('GPLv3',Yii::app()->getBaseUrl().'/GPL-3.0 License.txt'), '{GPLv3long}'=>CHtml::link(Yii::t('app','GNU General Public License version 3'),Yii::app()->getBaseUrl().'/GPL-3.0 License.txt') ));?><br /> <?php echo Yii::t('app','Generated in {time} seconds',array('{time}'=>round(CLogger::getExecutionTime(),3))); ?><br /> <?php $imghtml = CHtml::image($themeURL.'/images/x2touch.png',''); echo CHtml::link($imghtml,Yii::app()->getBaseUrl().'/index.php/x2touch'); ?> </div> </div> </body> </html>