本文整理汇总了PHP中XLite\Logger类的典型用法代码示例。如果您正苦于以下问题:PHP Logger类的具体用法?PHP Logger怎么用?PHP Logger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Logger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
/**
* Send message
*
* @return boolean
*/
public function send()
{
if (\XLite\Core\Config::getInstance()->XC->WebmasterKit->logMail) {
\XLite\Logger::getInstance()->logCustom('mail-messages', 'From: ' . $this->mail->From . PHP_EOL . 'To: ' . $this->get('to') . PHP_EOL . 'Subject: ' . $this->mail->Subject . PHP_EOL . $this->mail->Body . PHP_EOL . PHP_EOL);
}
return parent::send();
}
示例2: __construct
/**
* Constructor
* Creates directory for locks if needed
*/
public function __construct()
{
if (!\Includes\Utils\FileManager::isExists(rtrim(static::LOCK_DIR, LC_DS))) {
\Includes\Utils\FileManager::mkdirRecursive(rtrim(static::LOCK_DIR, LC_DS));
}
if (!\Includes\Utils\FileManager::isReadable(static::LOCK_DIR) || !\Includes\Utils\FileManager::isWriteable(static::LOCK_DIR)) {
\XLite\Logger::getInstance()->log('Cannot create lock for keys', LOG_DEBUG);
}
parent::__construct();
}
示例3: 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;
}
示例4: startEntityManager
/**
* Start Doctrine entity manager
*
* @return void
*/
public function startEntityManager()
{
parent::startEntityManager();
if (!defined('LC_CACHE_BUILDING')) {
if (\XLite\Module\XC\WebmasterKit\Core\Profiler::getInstance()->enabled) {
static::$em->getConnection()->getConfiguration()->setSQLLogger(\XLite\Module\XC\WebmasterKit\Core\Profiler::getInstance());
} elseif (\XLite\Core\Config::getInstance()->XC->WebmasterKit->logSQL) {
static::$em->getConnection()->getConfiguration()->setSQLLogger(\XLite\Logger::getInstance());
}
}
}
示例5: getModule
/**
* Return current module object
*
* @return \XLite\Model\Module
* @throws \Exception
*/
public function getModule()
{
if (!isset($this->module)) {
$this->module = \XLite\Core\Database::getRepo('\\XLite\\Model\\Module')->find($this->getModuleID());
if (!$this->module) {
\XLite\Core\TopMessage::addError('Add-on does not exist.');
\XLite\Logger::getInstance()->log('Add-on does not exist (ID: ' . $this->getModuleID() . ')', LOG_ERR);
$this->redirect($this->buildURL('addons_list_installed'));
}
}
return $this->module;
}
示例6: doActionCallback
/**
* Process callback
*
* @return void
*/
protected function doActionCallback()
{
$transaction = $this->detectTransaction();
if ($transaction) {
$this->transaction = $transaction;
$transaction->getPaymentMethod()->getProcessor()->processCallback($transaction);
$cart = $transaction->getOrder();
if ($cart instanceof \XLite\Model\Cart) {
$cart->tryClose();
}
$transaction->getOrder()->setPaymentStatusByTransaction($transaction);
$transaction->getOrder()->update();
\XLite\Core\Database::getEM()->flush();
} else {
\XLite\Logger::getInstance()->log('Request callback with undefined payment transaction' . PHP_EOL . 'Data: ' . var_export(\XLite\Core\Request::getInstance()->getData(), true), LOG_ERR);
}
$this->set('silent', true);
}
示例7: getRequestData
/**
* Get request data
*
* @return mixed
*/
public function getRequestData()
{
$data = null;
$validator = $this->getValidator();
try {
$validator->validate(\XLite\Core\Request::getInstance()->getData());
$data = $validator->sanitize(\XLite\Core\Request::getInstance()->getData());
} catch (\XLite\Core\Validator\Exception $exception) {
$message = static::t($exception->getMessage(), $exception->getLabelArguments());
if ($exception->isInternal()) {
\XLite\Logger::getInstance()->log($message, LOG_ERR);
} else {
\XLite\Core\Event::invalidElement($exception->getPath(), $message);
}
$this->validationMessage = ($exception->getPublicName() ? static::t($exception->getPublicName()) . ': ' : '') . $message;
}
return $data;
}
示例8: processItem
/**
* Process item
*
* @param mixed $item Item
*
* @return boolean
*/
protected function processItem($item)
{
$result = false;
$path = tempnam(LC_DIR_TMP, 'migrate_file');
file_put_contents($path, $item->getBody());
if (\Includes\Utils\FileManager::isExists($path)) {
$localPath = $item->isURL() ? null : $item->getStoragePath();
$result = $item->loadFromLocalFile($path, $item->getFileName() ?: basename($item->getPath()));
if ($result && $localPath && \Includes\Utils\FileManager::isExists($localPath)) {
\Includes\Utils\FileManager::deleteFile($localPath);
}
\Includes\Utils\FileManager::deleteFile($path);
}
if (!$result) {
if (!isset($this->record['s3_error_count'])) {
$this->record['s3_error_count'] = 0;
}
$this->record['s3_error_count']++;
\XLite\Logger::getInstance()->log('Couldn\'t move image ' . $item->getPath() . ' (local file system to Amazon S3)', LOG_ERR);
}
return true;
}
示例9: processItem
/**
* Process item
*
* @param mixed $item Item
*
* @return boolean
*/
protected function processItem($item)
{
$result = false;
$path = tempnam(LC_DIR_TMP, 'migrate_file');
file_put_contents($path, $item->getBody());
if (file_exists($path)) {
$item->setS3Forbid(true);
$localPath = $item->getStoragePath();
$result = $item->loadFromLocalFile($path, $item->getFileName() ?: basename($item->getPath()));
if ($localPath) {
\XLite\Module\CDev\AmazonS3Images\Core\S3::getInstance()->delete($localPath);
}
unlink($path);
}
if (!$result) {
if (!isset($this->record['s3_error_count'])) {
$this->record['s3_error_count'] = 0;
}
$this->record['s3_error_count']++;
\XLite\Logger::getInstance()->log('Couldn\'t move image ' . $item->getPath() . ' (Amazon S3 to local file system)', LOG_ERR);
}
return true;
}
示例10: uninstallModule
/**
* Uninstall module
*
* @param \XLite\Model\Module $module Module object
* @param array &$messages Messages list
*
* @return boolean
*/
public function uninstallModule(\XLite\Model\Module $module, &$messages)
{
$result = false;
// Get module pack
$pack = new \XLite\Core\Pack\Module($module);
$dirs = $pack->getDirs();
$nonWritableDirs = array();
// Check module directories permissions
foreach ($dirs as $dir) {
if (\Includes\Utils\FileManager::isExists($dir) && !\Includes\Utils\FileManager::isDirWriteable($dir)) {
$nonWritableDirs[] = \Includes\Utils\FileManager::getRelativePath($dir, LC_DIR_ROOT);
}
}
$params = array('name' => sprintf('%s v%s (%s)', $module->getModuleName(), $module->getVersion(), $module->getAuthorName()));
if (empty($nonWritableDirs)) {
$yamlData = array();
$yamlFiles = \Includes\Utils\ModulesManager::getModuleYAMLFiles($module->getAuthor(), $module->getName());
foreach ($yamlFiles as $yamlFile) {
$yamlData[] = \Includes\Utils\FileManager::read($yamlFile);
}
if (!$module->checkModuleMainClass()) {
$classFile = LC_DIR_CLASSES . \Includes\Utils\Converter::getClassFile($module->getMainClass());
if (\Includes\Utils\FileManager::isFileReadable($classFile)) {
require_once $classFile;
}
}
// Call uninstall event method
$r = $module->callModuleMethod('callUninstallEvent', 111);
if (111 == $r) {
\XLite\Logger::getInstance()->log($module->getActualName() . ': Method callUninstallEvent() was not called');
}
// Remove from FS
foreach ($dirs as $dir) {
\Includes\Utils\FileManager::unlinkRecursive($dir);
}
\Includes\Utils\ModulesManager::disableModule($module->getActualName());
\Includes\Utils\ModulesManager::removeModuleFromDisabledStructure($module->getActualName());
// Remove module from DB
try {
// Refresh module entity as it was changed by disableModule() method above
$module = $this->find($module->getModuleID());
$this->delete($module);
} catch (\Exception $e) {
$messages[] = $e->getMessage();
}
if ($module->getModuleID()) {
$messages[] = \XLite\Core\Translation::getInstance()->translate('A DB error occured while uninstalling the module X', $params);
} else {
if (!empty($yamlData)) {
foreach ($yamlData as $yaml) {
\XLite\Core\Database::getInstance()->unloadFixturesFromYaml($yaml);
}
}
$messages[] = \XLite\Core\Translation::getInstance()->translate('The module X has been uninstalled successfully', $params);
$result = true;
}
} else {
$messages[] = \XLite\Core\Translation::getInstance()->translate('Unable to delete module X files: some dirs have no writable permissions: Y', $params + array('dirs' => implode(', ', $nonWritableDirs)));
}
return $result;
}
示例11: display
/**
* Attempts to display widget using its template
*
* @param string $template Template file name OPTIONAL
*
* @return void
*/
public function display($template = null)
{
// todo: use meaning name
$flag = null !== $template;
if ($flag || $this->checkVisibility()) {
if (!$this->isCloned && !$flag) {
$this->initView();
}
$cacheAvailable = $this->isCacheAllowed($template);
$content = $cacheAvailable ? $this->getCachedContent() : null;
if (null !== $content) {
print $content;
} else {
if ($cacheAvailable) {
ob_start();
}
// Body of the old includeCompiledFile() method
list($this->currentSkin, $this->currentLocale, $normalized) = $this->getTemplateFile($template);
if (null === $normalized) {
\XLite\Logger::getInstance()->log(sprintf('Empty compiled template. View class: %s, view main template: %s', get_class($this), $this->getTemplate()), \LOG_DEBUG);
} else {
$compiled = \XLite\Singletons::$handler->flexy->prepare($normalized);
// Collect the specific data to send it to the finalizeTemplateDisplay method
$profilerData = $this->prepareTemplateDisplay($normalized);
static::$viewsTail[] = $normalized;
include $compiled;
array_pop(static::$viewsTail);
$this->finalizeTemplateDisplay($template, $profilerData);
}
if ($cacheAvailable) {
$this->setCachedContent(ob_get_contents());
ob_end_flush();
}
}
}
}
示例12: callAction
/**
* Call controller action
*
* @return void
*/
protected function callAction()
{
$action = $this->getAction();
$method = 'doAction' . \Includes\Utils\Converter::convertToPascalCase($action);
if (method_exists($this, $method)) {
// Call method doAction<action-name-in-camel-case>
$this->{$method}();
} else {
\XLite\Logger::getInstance()->log('Handler for the action "' . $action . '" is not defined for the "' . get_class($this) . '" class');
}
$this->actionPostprocess($action);
}
示例13: doActionCallback
/**
* Process callback
*
* @return void
*/
protected function doActionCallback()
{
$txn = null;
$txnIdName = 'txnId';
if (isset(\XLite\Core\Request::getInstance()->txn_id_name)) {
/**
* some of gateways can't accept return url on run-time and
* use the one set in merchant account, so we can't pass
* 'order_id' in run-time, instead pass the order id parameter name
*/
$txnIdName = \XLite\Core\Request::getInstance()->txn_id_name;
}
if (isset(\XLite\Core\Request::getInstance()->{$txnIdName})) {
$txn = \XLite\Core\Database::getRepo('XLite\\Model\\Payment\\Transaction')->find(\XLite\Core\Request::getInstance()->{$txnIdName});
}
if (!$txn) {
$methods = \XLite\Core\Database::getRepo('XLite\\Model\\Payment\\Method')->findAllActive();
foreach ($methods as $method) {
if (method_exists($method->getProcessor(), 'getCallbackOwnerTransaction')) {
$txn = $method->getProcessor()->getCallbackOwnerTransaction();
if ($txn) {
break;
}
}
}
}
if ($txn) {
$txn->getPaymentMethod()->getProcessor()->processCallback($txn);
$cart = $txn->getOrder();
if (!$cart->isOpen()) {
// TODO: move it to \XLite\Controller\ACustomer
if ($cart->isPayed()) {
$status = $txn->isCaptured() ? \XLite\Model\Order::STATUS_PROCESSED : \XLite\Model\Order::STATUS_AUTHORIZED;
} else {
if ($txn->isRefunded()) {
$status = \XLite\Model\Order::STATUS_DECLINED;
} elseif ($txn->isFailed()) {
$status = \XLite\Model\Order::STATUS_FAILED;
} else {
$status = \XLite\Model\Order::STATUS_QUEUED;
}
}
$cart->setStatus($status);
}
} else {
\XLite\Logger::getInstance()->log('Request callback with undefined payment transaction' . PHP_EOL . 'Data: ' . var_export(\XLite\Core\Request::getInstance()->getData(), true), LOG_ERR);
}
\XLite\Core\Database::getEM()->flush();
$this->set('silent', true);
}
示例14: 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)
{
if (\XLite\Core\Config::getInstance()->XC->AuctionInc->debugMode) {
\XLite\Logger::logCustom('AuctionInc', array('status' => $status, 'request' => $request, 'response' => $response));
}
}
示例15: 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);
}