Skip to content

Commit

Permalink
Merge branch 'feature/PLUG-805' of github.com:paynl/magento2-plugin--…
Browse files Browse the repository at this point in the history
…-private into feature/PLUG-805
  • Loading branch information
kevinverschoor committed Jan 28, 2022
2 parents 32d58af + 8253133 commit 52a1403
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
19 changes: 17 additions & 2 deletions Helper/PayHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

class PayHelper extends \Magento\Framework\App\Helper\AbstractHelper
{
const PAY_LOG_PREFIX = 'PAY.: ';

private static $objectManager;
private static $store;

Expand Down Expand Up @@ -68,6 +70,20 @@ public static function logDebug($text, $params = array(), $store = null)
self::writeLog($text, 'debug', $params, $store);
}

/**
* Logs while bypassing the loglevel setting.
*
* @param $text
* @param array $params
* @param null $store
*/
public static function log($text, $params = array(), $store = null)
{
$objectManager = self::getObjectManager();
$logger = $objectManager->get(\Psr\Log\LoggerInterface::class);
$logger->notice(PayHelper::PAY_LOG_PREFIX . $text, $params);
}

public static function writeLog($text, $type, $params, $store)
{
$objectManager = self::getObjectManager();
Expand All @@ -77,8 +93,7 @@ public static function writeLog($text, $type, $params, $store)
$level = $store->getConfig('payment/paynl/logging_level');

if (self::hasCorrectLevel($level, $type)) {
$prefix = 'PAY.: ';
$text = $prefix . $text;
$text = PayHelper::PAY_LOG_PREFIX . $text;
if (!is_array($params)) {
$params = array();
}
Expand Down
4 changes: 3 additions & 1 deletion Setup/Patch/Data/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ public function apply()
$this->moduleDataSetup->startSetup();

if (empty($this->store->getConfig('payment/paynl/apitoken')) && empty($this->store->getConfig('payment/paynl/serviceid'))) {
payHelper::logDebug('Installing module.');
payHelper::log('Installing module');
$this->configWriter->save('payment/paynl/order_description_prefix', 'Order ');
$this->configWriter->save('payment/paynl/image_style', 'newest');
$this->configWriter->save('payment/paynl/pay_style_checkout', 1);
$this->configWriter->save('payment/paynl/icon_size', 'small');
} else {
payHelper::logInfo('Installing, keeping defaults.');
}

$this->moduleDataSetup->endSetup();
Expand Down
4 changes: 2 additions & 2 deletions Setup/Patch/Data/UpdateFashionGiftcard.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function apply()
{
$this->moduleDataSetup->startSetup();

payHelper::logDebug('Apply patch: updateFashionGiftcard.');
payHelper::log('Apply patch: updateFashionGiftcard.');

$connection = $this->resourceConnection->getConnection();
$tableName = $this->resourceConnection->getTableName('core_config_data');
Expand All @@ -54,7 +54,7 @@ public function apply()
if (!$result) {
return;
}
payHelper::logDebug('updateFashionGiftcard result ' . $result);
payHelper::log('updateFashionGiftcard result ' . $result);
if ($result == '1699') {
# Update the incorrect profileid.
$this->resourceConfig->saveConfig($path, '1669', 'default', 0);
Expand Down

0 comments on commit 52a1403

Please sign in to comment.