本文整理汇总了PHP中XLite\Logger::logCustom方法的典型用法代码示例。如果您正苦于以下问题:PHP Logger::logCustom方法的具体用法?PHP Logger::logCustom怎么用?PHP Logger::logCustom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XLite\Logger
的用法示例。
在下文中一共展示了Logger::logCustom方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: performMap
/**
* Perform actual mapping
*
* @return mixed
*/
protected function performMap()
{
$response = json_decode($this->inputData->body);
$result = null;
if (isset($response->error)) {
\XLite\Logger::logCustom("PitneyBowes", 'ConfirmOrder: ' . $response->error . ' - ' . $response->message, false);
} else {
$result = $response;
}
return $result;
}
示例2: doQuery
/**
* Performs request to USPS server and returns array of rates
*
* @param array $data Array of request parameters
* @param boolean $ignoreCache Flag: if true then do not get rates from cache
*
* @return array
*/
protected function doQuery($data, $ignoreCache)
{
$result = null;
$rates = array();
$availableMethods = \XLite\Core\Database::getRepo('XLite\\Model\\Shipping\\Method')->findMethodsByProcessor($this->getProcessorId());
if ($availableMethods) {
$xmlData = $this->getXMLData($data);
$currencyRate = doubleval(\XLite\Core\Config::getInstance()->CDev->USPS->currency_rate);
$currencyRate = 0 < $currencyRate ? $currencyRate : 1;
$postURL = $this->getApiURL() . '?API=' . $this->getApiName() . '&XML=' . urlencode(preg_replace('/>(\\s+)</', '><', $xmlData));
try {
if (!$ignoreCache) {
$cachedRate = $this->getDataFromCache($postURL);
}
if (isset($cachedRate)) {
// Get rates from cache
$result = $cachedRate;
} elseif (\XLite\Model\Shipping::isIgnoreLongCalculations()) {
// Ignore rates calculation
return array();
} else {
// Calculate rate
$bouncer = new \XLite\Core\HTTP\Request($postURL);
$bouncer->requestTimeout = 5;
$response = $bouncer->sendRequest();
if ($response && 200 == $response->code) {
$result = $response->body;
$this->saveDataInCache($postURL, $result);
if (\XLite\Core\Config::getInstance()->CDev->USPS->debug_enabled) {
\XLite\Logger::logCustom('USPS', var_export(array('Request URL' => $postURL, 'Request XML' => $xmlData, 'Response' => \XLite\Core\XML::getInstance()->getFormattedXML($result)), true));
}
} else {
$this->errorMsg = sprintf('Error while connecting to the USPS host (%s)', $this->getApiURL());
}
}
$response = isset($this->errorMsg) ? array() : $this->parseResponse($result);
$this->apiCommunicationLog[] = array('request' => $postURL, 'xml' => htmlentities(preg_replace('/(USERID=")([^"]+)/', '\\1***', $xmlData)), 'response' => htmlentities(\XLite\Core\XML::getInstance()->getFormattedXML($result)));
if (!isset($this->errorMsg) && !isset($response['err_msg']) && !empty($response['postage'])) {
foreach ($response['postage'] as $postage) {
$rate = new \XLite\Model\Shipping\Rate();
$method = $this->getShippingMethod($postage['CLASSID'], $availableMethods);
if (!isset($method)) {
// Unknown method received: add this to the database with disabled status
$method = $this->addShippingMethod($postage);
}
if ($method && $method->getEnabled()) {
// Method is registered and enabled
$rate->setMethod($method);
$codPrice = 0;
$rateValue = doubleval($postage['Rate']);
if (!$this->isStaticCODPrice() && isset($postage['SpecialServices'])) {
if (isset($postage['SpecialServices'][6]) && 'true' == $postage['SpecialServices'][6]['Available']) {
// Shipping service supports COD
$extraData = new \XLite\Core\CommonCell();
$extraData->cod_supported = true;
$extraData->cod_rate = ($rateValue + doubleval($postage['SpecialServices'][6]['Price'])) * $currencyRate;
$rate->setExtraData($extraData);
if ($data['cod_enabled']) {
// Calculate COD fee if COD payment method is selected
$codPrice = doubleval($postage['SpecialServices'][6]['Price']);
}
}
} elseif ($this->isStaticCODPrice() && $this->isMethodSupportCOD($method)) {
$codStaticPrice = doubleval(\XLite\Core\Config::getInstance()->CDev->USPS->cod_price);
if (0 < $codStaticPrice) {
// Shipping service supports COD
$extraData = new \XLite\Core\CommonCell();
$extraData->cod_supported = true;
$extraData->cod_rate = ($rateValue + $codStaticPrice) * $currencyRate;
$rate->setExtraData($extraData);
if ($data['cod_enabled']) {
// Calculate COD fee if COD payment method is selected
$codPrice = $codStaticPrice;
}
}
}
// Base rate is a sum of base rate and COD fee
$rate->setBaseRate(($rateValue + $codPrice) * $currencyRate);
if (isset($rates[$postage['MailService']])) {
// Multipackaging: sum base rate and COD fee for each rated packages
$rates[$postage['MailService']]->setBaseRate($rates[$postage['MailService']]->getBaseRate() + $rate->getBaseRate());
if ($rate->getExtraData()->cod_rate) {
$extra = $rates[$postage['MailService']]->getExtraData();
$extra->cod_rate = $extra->cod_rate + $rate->getExtraData()->cod_rate;
$rates[$postage['MailService']]->setExtraData($extra);
}
} else {
$rates[$postage['MailService']] = $rate;
}
}
}
} elseif (!isset($this->errorMsg)) {
//.........这里部分代码省略.........
示例3: addLog
/**
* Add record to the module log file
*
* @param string $message Text message OPTIONAL
* @param mixed $data Data (can be any type) OPTIONAL
*
* @return void
*/
public static function addLog($message = null, $data = null)
{
if ($message && $data) {
$msg = array('message' => $message, 'data' => $data);
} else {
$msg = $message ?: ($data ?: null);
}
if (!is_string($msg)) {
$msg = var_export($msg, true);
}
\XLite\Logger::logCustom(self::getModuleName(), $msg);
}
示例4: log
/**
* Logging the data under Velocity
* Available if developer_mode is on in the config file
*
* @param mixed $data
*
* @return void
*/
protected static function log($data)
{
if (LC_DEVELOPER_MODE) {
\XLite\Logger::logCustom('Velocity', $data);
}
}
示例5: getShippingAdressByDstAddressArray
/**
* Retrieve shipping adress from dstAddress
*
* @return array
*/
protected function getShippingAdressByDstAddressArray(array $dstAddress)
{
$state = null;
if ($dstAddress['state'] && is_numeric($dstAddress['state'])) {
$stateObject = \XLite\Core\Database::getRepo('XLite\\Model\\State')->find($dstAddress['state']);
if ($stateObject) {
$state = $stateObject->getCode();
}
} elseif ($dstAddress['custom_state']) {
$state = $dstAddress['custom_state'];
}
if (!$state) {
\XLite\Logger::logCustom("PitneyBowes", 'Problem with state', false);
}
return array('street1' => $dstAddress['address'] ?: '', 'city' => $dstAddress['city'], 'provinceOrState' => $state, 'country' => $dstAddress['country'], 'postalOrZipCode' => $dstAddress['zipcode']);
}
示例6: logDebug
/**
* Debug logging
*
* @param mixed $message Message
* @param mixed $message Message
*
* @return void
*/
public static function logDebug($message, $backtrace = false)
{
if (static::getProcessorConfiguration()->debug_enabled) {
\XLite\Logger::logCustom('PitneyBowesDebug', $message, $backtrace);
}
}
示例7: logResponse
/**
* Add log message
*
* @param boolean $status Status
* @param array $request Request data
* @param array $response Response data
*
* @return void
*/
protected function logResponse($status, $request, $response)
{
$config = $this->getConfiguration();
if ($config->debugMode) {
\XLite\Logger::logCustom('AuctionInc', array('status' => $status, 'request' => $request, 'response' => $response));
}
}
示例8: func_amazon_pa_error
public static function func_amazon_pa_error($message)
{
\XLite\Logger::logCustom('amazon_pa', $message);
return true;
}
示例9: doQuery
/**
* doQuery
*
* @param mixed $data Can be either \XLite\Model\Order instance or an array
* @param boolean $ignoreCache Flag: if true then do not get rates from cache
*
* @return void
*/
protected function doQuery($data, $ignoreCache)
{
$rates = array();
// Get all available rates
$availableMethods = \XLite\Core\Database::getRepo('XLite\\Model\\Shipping\\Method')->findMethodsByProcessor($this->getProcessorId(), !$ignoreCache);
if ($availableMethods) {
// Do rates calculation if there are enabled shipping methods or calculation test is running
$xmlData = $this->getXMLData($data);
$postData = preg_split("/(\r\n|\r|\n)/", $xmlData, -1, PREG_SPLIT_NO_EMPTY);
$postURL = $this->getApiURL();
try {
if (!$ignoreCache) {
$cachedRate = $this->getDataFromCache($xmlData);
}
if (isset($cachedRate)) {
$result = $cachedRate;
} elseif (\XLite\Model\Shipping::isIgnoreLongCalculations()) {
// Ignore rates calculation
return array();
} else {
// Prepare request XML for logging
$xmlDataLog = preg_replace('|<AccessLicenseNumber>.+</AccessLicenseNumber>|i', '<AccessLicenseNumber>xxx</AccessLicenseNumber>', $xmlData);
$xmlDataLog = preg_replace('|<UserId>.+</UserId>|i', '<UserId>xxx</UserId>', $xmlDataLog);
$xmlDataLog = preg_replace('|<Password>.+</Password>|i', '<Password>xxx</Password>', $xmlDataLog);
$xmlDataLog = preg_replace('|<ShipperNumber>.+</ShipperNumber>|i', '<ShipperNumber>xxx</ShipperNumber>', $xmlDataLog);
// Do request
$bouncer = new \XLite\Core\HTTP\Request($postURL . '/Rate');
$bouncer->body = $xmlData;
$bouncer->verb = 'POST';
$bouncer->requestTimeout = 5;
$response = $bouncer->sendRequest();
if (200 == $response->code || !empty($response->body)) {
$result = $response->body;
if (200 == $response->code) {
$this->saveDataInCache($xmlData, $result);
}
if (\XLite\Core\Config::getInstance()->XC->UPS->debug_enabled) {
\XLite\Logger::logCustom('UPS', var_export(array('Request URL' => $postURL, 'Request XML' => $xmlDataLog, 'Response XML' => \XLite\Core\XML::getInstance()->getFormattedXML($result)), true));
}
} else {
$this->errorMsg = sprintf('Error while connecting to the UPS server (%s)', $this->getApiURL());
}
}
if (!isset($this->errorMsg)) {
$response = $this->parseResponse($result);
} else {
$response = array();
}
// Save communication log for test request only (ignoreCache is set for test requests only)
if ($ignoreCache === true) {
$this->apiCommunicationLog[] = array('post URL' => $postURL, 'request' => htmlentities($xmlDataLog), 'response' => htmlentities(\XLite\Core\XML::getInstance()->getFormattedXML($result)));
}
if (!isset($this->errorMsg) && !isset($response['err_msg'])) {
foreach ($response as $row) {
$method = $this->getShippingMethod($row['serviceCode'], $data['srcAddress']['country'], $availableMethods);
if ($method) {
$rate = new \XLite\Model\Shipping\Rate();
$rate->setBaseRate($row['totalCharges']);
$rate->setMethod($method);
$extraData = null;
if (!empty($row['deliveryTime'])) {
$extraData = new \XLite\Core\CommonCell();
$extraData->deliveryDays = $row['deliveryTime'];
$rate->setExtraData($extraData);
}
if ($data['cod_enabled'] && $this->isCODAllowed('all', $data['srcAddress']['country'], $data['dstAddress']['country'])) {
$extraData = $extraData ?: new \XLite\Core\CommonCell();
$extraData->cod_supported = true;
$extraData->cod_rate = $rate->getBaseRate();
$rate->setExtraData($extraData);
}
$rates[] = $rate;
}
}
} elseif (!isset($this->errorMsg)) {
$this->errorMsg = isset($response['err_msg']) ? $response['err_msg'] : 'Unknown error';
}
} catch (\Exception $e) {
$this->errorMsg = 'Exception: ' . $e->getMessage();
}
}
return $rates;
}
示例10: parseResponse
/**
* Parses response and returns an associative array
*
* @param string $stringData Response received from FedEx
*
* @return array
*/
protected function parseResponse($stringData)
{
$result = array();
$xml = \XLite\Core\XML::getInstance();
$xmlParsed = $xml->parse($stringData, $err);
if (isset($xmlParsed['soapenv:Envelope']['#']['soapenv:Body'][0]['#']['soapenv:Fault'][0]['#'])) {
// FedEx responses with error of request validation
$result['err_msg'] = $xml->getArrayByPath($xmlParsed, 'soapenv:Envelope/#/soapenv:Body/0/#/soapenv:Fault/0/#/faultstring/0/#');
} else {
$rateReply = $xml->getArrayByPath($xmlParsed, 'SOAP-ENV:Envelope/#/SOAP-ENV:Body/0/#/RateReply/0/#');
$errorCodes = array('FAILURE', 'ERROR');
if (in_array($xml->getArrayByPath($rateReply, 'HighestSeverity/0/#'), $errorCodes)) {
// FedEx failed to return valid rates
$result['err_msg'] = $xml->getArrayByPath($rateReply, 'Notifications/0/#/Message/0/#');
$result['err_code'] = $xml->getArrayByPath($rateReply, 'Notifications/0/#/Code/0/#');
} else {
// Success
$rateDetails = $xml->getArrayByPath($rateReply, 'RateReplyDetails');
if (!empty($rateDetails) && is_array($rateDetails)) {
$conversionRate = $this->getCurrencyConversionRate();
foreach ($rateDetails as $rate) {
$serviceType = $xml->getArrayByPath($rate, '#/ServiceType/0/#');
$result[$serviceType]['amount'] = $this->getRateAmount($rate);
$variableHandlingCharge = $xml->getArrayByPath($rate, '#/RatedShipmentDetails/ShipmentRateDetail/TotalVariableHandlingCharges/VariableHandlingCharge/Amount/0/#');
$result[$serviceType]['amount'] += floatval($variableHandlingCharge);
if (1 != $conversionRate) {
$result[$serviceType]['amount'] *= $conversionRate;
}
}
}
}
}
// Log error
if (isset($result['err_msg'])) {
\XLite\Logger::logCustom('FEDEX', var_export(array('Error' => $result['err_msg'], 'Response' => \XLite\Core\XML::getInstance()->getFormattedXML($stringData)), true));
}
return $result;
}
示例11: doRequest
/**
* Do request to AustraliaPost API and receive response
*
* @param string $type Request type
* @param array $params Array of parameters
* @param boolean $ignoreCache Flag: ignore cache
*
* @return array|null
*/
protected function doRequest($type, $params = array(), $ignoreCache = false)
{
$result = null;
$requestType = $this->getApiRequestType($type);
$methodName = 'getRequestData' . $type;
if (method_exists($this, $methodName)) {
// Call method to prepare request data
$data = $this->{$methodName}($params);
} else {
$data = array();
}
// Validate request data
if ($this->validateRequestData($requestType, $data)) {
// Prepare post data
$postData = array();
foreach ($data as $key => $value) {
if (in_array($key, array('option_code', 'suboption_code'))) {
foreach ($value as $opcode) {
$postData[] = sprintf('%s=%s', $key, $opcode);
}
} else {
$postData[] = sprintf('%s=%s', $key, $value);
}
}
$postURL = $this->getApiURL() . $requestType['uri'] . '.json?' . implode('&', $postData);
if (!$ignoreCache) {
// Try to get cached result
$cachedRate = $this->getDataFromCache($postURL . $this->getApiKey());
}
if (isset($cachedRate)) {
// Get result from cache
$result = $cachedRate;
} elseif (\XLite\Model\Shipping::isIgnoreLongCalculations()) {
// Ignore rates calculation
return array();
} else {
// Get result from AustraliaPost server
try {
$headers = array('AUTH-KEY: ' . $this->getApiKey());
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $postURL);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
if (\XLite\Core\Config::getInstance()->CDev->AustraliaPost->test_mode) {
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
}
$response = curl_exec($ch);
if (!empty($response)) {
$result = json_decode($response, true);
if (!empty($result['error'])) {
$this->errorMsg = $result['error']['errorMessage'];
} else {
$this->saveDataInCache($postURL . $this->getApiKey(), $result);
}
} else {
$this->errorMsg = sprintf('Error while connecting to the AustraliaPost host (%s)', $postURL);
}
if ($ignoreCache === true) {
// Prepare data to display on Test AustraliaPost page
$this->apiCommunicationLog[] = array('request' => $postURL, 'response' => htmlentities($response), 'parsed' => $result);
}
if (\XLite\Core\Config::getInstance()->CDev->AustraliaPost->debug_enabled) {
// Log request and response
$log = array('postURL' => $postURL, 'data' => $data, 'result' => $result);
\XLite\Logger::logCustom('AUSPOST', var_export($log, true));
}
} catch (\Exception $e) {
$this->errorMsg = $e->getMessage();
}
}
}
return $result;
}
示例12: mapSingleQuote
/**
* Map single quote
*
* @param mixed $quote Single quote line
*
* @return \XLite\Model\Shipping\Rate
*/
protected function mapSingleQuote($quote)
{
$rate = null;
if (isset($quote->total->value)) {
$rate = new \XLite\Model\Shipping\Rate();
$rate->setBaseRate($this->getBaseRate($quote));
$method = Processor\PitneyBowes::getMethod($this->getMethodCode($quote));
$rate->setMethod($method);
$rate->setMarkupRate($this->getMarkupRate($quote));
if (isset($quote->totalTransportation->minDays) || isset($quote->totalTransportation->maxDays)) {
$extraData = new \XLite\Core\CommonCell();
$extraData->deliveryMinDays = $quote->totalTransportation->minDays + intval($this->config->min_delivery_adjustment);
$extraData->deliveryMaxDays = $quote->totalTransportation->maxDays + intval($this->config->max_delivery_adjustment);
$rate->setExtraData($extraData);
}
}
if (isset($quote->errors)) {
foreach ($quote->errors as $error) {
\XLite\Logger::logCustom("PitneyBowes", $error->error, false);
}
}
return $rate;
}
示例13: runSubmit
/**
* Run catalog submission
*
* @param boolean $diff Perform differential extraction (default: false, full extraction)
*
* @return void
*/
protected function runSubmit($diff = false)
{
\XLite\Logger::logCustom("PitneyBowes", 'Submitting catalog (diff: ' . var_export($diff, true) . ')', false);
\XLite\Logic\Export\Generator::run(\XLite\Logic\Export\Generator::getPBExportOptions(array('differential' => $diff)));
$running = \XLite\Logic\Export\Generator::runHeadless();
//submit to pb
if (!$running) {
$config = $this->getConfiguration();
$processor = new PitneyBowes\Logic\FileExchange\Processor($config);
$generator = $this->getGenerator();
if ($generator) {
$processor->submitCatalog($generator->getCatalogFiles(), $generator->getOptions()->differential);
}
}
}
示例14: getMapped
/**
* @return mixed
*/
public function getMapped()
{
$result = null;
if ($this->isApplicable()) {
$result = $this->postProcessMapped($this->performMap());
} elseif ($this->nextMapper) {
$this->nextMapper->setInputData($this->inputData);
$result = $this->nextMapper->getMapped();
} else {
\XLite\Logger::logCustom("PitneyBowes", 'Internal error in mapper ' . get_class($this), false);
}
return $result;
}
示例15: getController
/**
* Get controller
*
* @return \XLite\Controller\AController
*/
public static function getController()
{
if (null === static::$controller) {
$class = static::getControllerClass();
if (!$class) {
\XLite\Core\Request::getInstance()->target = static::TARGET_DEFAULT;
\XLite\Logger::logCustom('access', 'Controller class ' . $class . ' not found!');
\XLite\Core\Request::getInstance()->target = static::TARGET_404;
$class = static::getControllerClass();
}
if (!\XLite\Core\Request::getInstance()->isCLI() && \XLite::getInstance()->getRequestedScript() !== \XLite::getInstance()->getExpectedScript() && \XLite::getInstance()->getRequestedScript() !== \XLite::getInstance()->getExpectedScript(true)) {
\XLite\Core\Request::getInstance()->target = static::TARGET_404;
$class = static::getControllerClass();
}
static::$controller = new $class(\XLite\Core\Request::getInstance()->getData());
static::$controller->init();
}
return static::$controller;
}