Skip to content

Commit

Permalink
Merge pull request #2 from magento-south/MAGETWO-13915
Browse files Browse the repository at this point in the history
PSR-3: common interface for logging libraries
  • Loading branch information
vpelipenko committed Dec 25, 2014
2 parents 6e74547 + db238ee commit 59f1a97
Show file tree
Hide file tree
Showing 462 changed files with 2,068 additions and 1,811 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac

/**
* @param \Magento\Core\Model\EntityFactory $entityFactory
* @param \Magento\Framework\Logger $logger
* @param \Psr\Log\LoggerInterface $logger
* @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy
* @param \Magento\Framework\Event\ManagerInterface $eventManager
* @param \Magento\Framework\Notification\MessageList $messageList
Expand All @@ -31,7 +31,7 @@ class Collection extends \Magento\Framework\Model\Resource\Db\Collection\Abstrac
*/
public function __construct(
\Magento\Core\Model\EntityFactory $entityFactory,
\Magento\Framework\Logger $logger,
\Psr\Log\LoggerInterface $logger,
\Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy,
\Magento\Framework\Event\ManagerInterface $eventManager,
\Magento\Framework\Notification\MessageList $messageList,
Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/Authorization/Model/Acl/AclRetriever.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Magento\Framework\Acl\Builder as AclBuilder;
use Magento\Framework\Exception\AuthorizationException;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Logger;
use Psr\Log\LoggerInterface as Logger;

/**
* Permission tree retriever
Expand Down Expand Up @@ -79,7 +79,7 @@ public function getAllowedResourcesByUser($userType, $userId)
} catch (AuthorizationException $e) {
throw $e;
} catch (\Exception $e) {
$this->logger->logException($e);
$this->logger->critical($e);
throw new LocalizedException(
'Error happened while getting a list of allowed resources. Check exception log for details.'
);
Expand Down
8 changes: 4 additions & 4 deletions app/code/Magento/Authorization/Model/Resource/Rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@ class Rules extends \Magento\Framework\Model\Resource\Db\AbstractDb
protected $_aclBuilder;

/**
* @var \Magento\Framework\Logger
* @var \Psr\Log\LoggerInterface
*/
protected $_logger;

/**
* @param \Magento\Framework\App\Resource $resource
* @param \Magento\Framework\Acl\Builder $aclBuilder
* @param \Magento\Framework\Logger $logger
* @param \Psr\Log\LoggerInterface $logger
* @param \Magento\Framework\Acl\RootResource $rootResource
* @param \Magento\Framework\Acl\CacheInterface $aclCache
*/
public function __construct(
\Magento\Framework\App\Resource $resource,
\Magento\Framework\Acl\Builder $aclBuilder,
\Magento\Framework\Logger $logger,
\Psr\Log\LoggerInterface $logger,
\Magento\Framework\Acl\RootResource $rootResource,
\Magento\Framework\Acl\CacheInterface $aclCache
) {
Expand Down Expand Up @@ -116,7 +116,7 @@ public function saveRel(\Magento\Authorization\Model\Rules $rule)
throw $e;
} catch (\Exception $e) {
$adapter->rollBack();
$this->_logger->logException($e);
$this->_logger->critical($e);
}
}
}
4 changes: 2 additions & 2 deletions app/code/Magento/Backend/Block/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Context extends \Magento\Framework\View\Element\Context
* @param \Magento\Framework\View\Asset\Repository $assetRepo
* @param \Magento\Framework\View\ConfigInterface $viewConfig
* @param \Magento\Framework\App\Cache\StateInterface $cacheState
* @param \Magento\Framework\Logger $logger
* @param \Psr\Log\LoggerInterface $logger
* @param \Magento\Framework\Escaper $escaper
* @param \Magento\Framework\Filter\FilterManager $filterManager
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
Expand All @@ -55,7 +55,7 @@ public function __construct(
\Magento\Framework\View\Asset\Repository $assetRepo,
\Magento\Framework\View\ConfigInterface $viewConfig,
\Magento\Framework\App\Cache\StateInterface $cacheState,
\Magento\Framework\Logger $logger,
\Psr\Log\LoggerInterface $logger,
\Magento\Framework\Escaper $escaper,
\Magento\Framework\Filter\FilterManager $filterManager,
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/Backend/Block/Template/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Context extends \Magento\Framework\View\Element\Template\Context
* @param \Magento\Framework\View\Asset\Repository $assetRepo
* @param \Magento\Framework\View\ConfigInterface $viewConfig
* @param \Magento\Framework\App\Cache\StateInterface $cacheState
* @param \Magento\Framework\Logger $logger
* @param \Psr\Log\LoggerInterface $logger
* @param \Magento\Framework\Escaper $escaper
* @param \Magento\Framework\Filter\FilterManager $filterManager
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
Expand Down Expand Up @@ -89,7 +89,7 @@ public function __construct(
\Magento\Framework\View\Asset\Repository $assetRepo,
\Magento\Framework\View\ConfigInterface $viewConfig,
\Magento\Framework\App\Cache\StateInterface $cacheState,
\Magento\Framework\Logger $logger,
\Psr\Log\LoggerInterface $logger,
\Magento\Framework\Escaper $escaper,
\Magento\Framework\Filter\FilterManager $filterManager,
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/Backend/Block/Widget/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Context extends \Magento\Backend\Block\Template\Context
* @param \Magento\Framework\View\Asset\Repository $assetRepo
* @param \Magento\Framework\View\ConfigInterface $viewConfig
* @param \Magento\Framework\App\Cache\StateInterface $cacheState
* @param \Magento\Framework\Logger $logger
* @param \Psr\Log\LoggerInterface $logger
* @param \Magento\Framework\Escaper $escaper
* @param \Magento\Framework\Filter\FilterManager $filterManager
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
Expand Down Expand Up @@ -74,7 +74,7 @@ public function __construct(
\Magento\Framework\View\Asset\Repository $assetRepo,
\Magento\Framework\View\ConfigInterface $viewConfig,
\Magento\Framework\App\Cache\StateInterface $cacheState,
\Magento\Framework\Logger $logger,
\Psr\Log\LoggerInterface $logger,
\Magento\Framework\Escaper $escaper,
\Magento\Framework\Filter\FilterManager $filterManager,
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected function _getFormat()
\Magento\Framework\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM
);
} catch (\Exception $e) {
$this->_logger->logException($e);
$this->_logger->critical($e);
}
}
$format = self::$_format;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected function _getFormat()
\Magento\Framework\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM
);
} catch (\Exception $e) {
$this->_logger->logException($e);
$this->_logger->critical($e);
}
}
$format = self::$_format;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function execute()
->setContents($response->getBody());
return $resultRaw;
} catch (\Exception $e) {
$this->_objectManager->get('Magento\Framework\Logger')->logException($e);
$this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e);
$error = __('see error log for details');
$httpCode = 503;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ public function execute()
) && $flagData['timeout_reached'])
) {
$this->_objectManager->get(
'Magento\Framework\Logger'
)->logException(
'Psr\Log\LoggerInterface'
)->critical(
new \Magento\Framework\Exception(
__('The timeout limit for response from synchronize process was reached.')
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function execute()
try {
$this->_getSyncSingleton()->synchronize($storage);
} catch (\Exception $e) {
$this->_objectManager->get('Magento\Framework\Logger')->logException($e);
$this->_objectManager->get('Psr\Log\LoggerInterface')->critical($e);
$flag->passError($e);
}

Expand Down
21 changes: 7 additions & 14 deletions app/code/Magento/Backend/Model/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
*/
class Menu extends \ArrayObject
{
/**
* Name of special logger key for debugging building menu
*/
const LOGGER_KEY = 'menu-debug';

/**
* Path in tree structure
*
Expand All @@ -22,15 +17,15 @@ class Menu extends \ArrayObject
protected $_path = '';

/**
* @var \Magento\Framework\Logger
* @var \Psr\Log\LoggerInterface
*/
protected $_logger;

/**
* @param \Magento\Framework\Logger $logger
* @param \Psr\Log\LoggerInterface $logger
* @param string $pathInMenuStructure
*/
public function __construct(\Magento\Framework\Logger $logger, $pathInMenuStructure = '')
public function __construct(\Psr\Log\LoggerInterface $logger, $pathInMenuStructure = '')
{
if ($pathInMenuStructure) {
$this->_path = $pathInMenuStructure . '/';
Expand Down Expand Up @@ -60,9 +55,8 @@ public function add(\Magento\Backend\Model\Menu\Item $item, $parentId = null, $i
$index = intval($index);
if (!isset($this[$index])) {
$this->offsetSet($index, $item);
$this->_logger->logDebug(
sprintf('Add of item with id %s was processed', $item->getId()),
self::LOGGER_KEY
$this->_logger->info(
sprintf('Add of item with id %s was processed', $item->getId())
);
} else {
$this->add($item, $parentId, $index + 1);
Expand Down Expand Up @@ -126,9 +120,8 @@ public function remove($itemId)
if ($item->getId() == $itemId) {
unset($this[$key]);
$result = true;
$this->_logger->logDebug(
sprintf('Remove on item with id %s was processed', $item->getId()),
self::LOGGER_KEY
$this->_logger->info(
sprintf('Remove on item with id %s was processed', $item->getId())
);
break;
}
Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/Backend/Model/Menu/AbstractDirector.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ public function __construct(\Magento\Backend\Model\Menu\Builder\CommandFactory $
*
* @param array $config
* @param \Magento\Backend\Model\Menu\Builder $builder
* @param \Magento\Framework\Logger $logger
* @param \Psr\Log\LoggerInterface $logger
* @return void
*/
abstract public function direct(
array $config,
\Magento\Backend\Model\Menu\Builder $builder,
\Magento\Framework\Logger $logger
\Psr\Log\LoggerInterface $logger
);
}
16 changes: 6 additions & 10 deletions app/code/Magento/Backend/Model/Menu/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Config
protected $_menu;

/**
* @var \Magento\Framework\Logger
* @var \Psr\Log\LoggerInterface
*/
protected $_logger;

Expand Down Expand Up @@ -64,7 +64,7 @@ class Config
* @param \Magento\Backend\Model\Menu\Config\Reader $configReader
* @param \Magento\Framework\App\Cache\Type\Config $configCacheType
* @param \Magento\Framework\Event\ManagerInterface $eventManager
* @param \Magento\Framework\Logger $logger
* @param \Psr\Log\LoggerInterface $logger
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param \Magento\Framework\App\State $appState
*/
Expand All @@ -75,7 +75,7 @@ public function __construct(
\Magento\Backend\Model\Menu\Config\Reader $configReader,
\Magento\Framework\App\Cache\Type\Config $configCacheType,
\Magento\Framework\Event\ManagerInterface $eventManager,
\Magento\Framework\Logger $logger,
\Psr\Log\LoggerInterface $logger,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Framework\App\State $appState
) {
Expand All @@ -101,21 +101,17 @@ public function __construct(
*/
public function getMenu()
{
if ($this->_scopeConfig->getValue('dev/log/active', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)) {
$this->_logger->addStreamLog(\Magento\Backend\Model\Menu::LOGGER_KEY);
}

try {
$this->_initMenu();
return $this->_menu;
} catch (\InvalidArgumentException $e) {
$this->_logger->logException($e);
$this->_logger->critical($e);
throw $e;
} catch (\BadMethodCallException $e) {
$this->_logger->logException($e);
$this->_logger->critical($e);
throw $e;
} catch (\OutOfRangeException $e) {
$this->_logger->logException($e);
$this->_logger->critical($e);
throw $e;
} catch (\Exception $e) {
throw $e;
Expand Down
11 changes: 5 additions & 6 deletions app/code/Magento/Backend/Model/Menu/Director/Director.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@ class Director extends \Magento\Backend\Model\Menu\AbstractDirector
* Get command object
*
* @param array $data command params
* @param \Magento\Framework\Logger $logger
* @param \Psr\Log\LoggerInterface $logger
* @return \Magento\Backend\Model\Menu\Builder\AbstractCommand
*/
protected function _getCommand($data, $logger)
{
$command = $this->_commandFactory->create($data['type'], ['data' => $data]);
if (isset($this->_messagePatterns[$data['type']])) {
$logger->logDebug(
sprintf($this->_messagePatterns[$data['type']], $command->getId()),
\Magento\Backend\Model\Menu::LOGGER_KEY
$logger->info(
sprintf($this->_messagePatterns[$data['type']], $command->getId())
);
}
return $command;
Expand All @@ -37,10 +36,10 @@ protected function _getCommand($data, $logger)
*
* @param array $config
* @param \Magento\Backend\Model\Menu\Builder $builder
* @param \Magento\Framework\Logger $logger
* @param \Psr\Log\LoggerInterface $logger
* @return void
*/
public function direct(array $config, \Magento\Backend\Model\Menu\Builder $builder, \Magento\Framework\Logger $logger)
public function direct(array $config, \Magento\Backend\Model\Menu\Builder $builder, \Psr\Log\LoggerInterface $logger)
{
foreach ($config as $data) {
$builder->processCommand($this->_getCommand($data, $logger));
Expand Down
17 changes: 0 additions & 17 deletions app/code/Magento/Backend/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -193,23 +193,6 @@
<comment>Translate, blocks and other output caches should be disabled for both frontend and admin inline translations.</comment>
</field>
</group>
<group id="log" translate="label" type="text" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Log Settings</label>
<field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enabled</label>
<source_model>Magento\Backend\Model\Config\Source\Yesno</source_model>
</field>
<field id="file" translate="label comment" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1">
<label>System Log File Name</label>
<backend_model>Magento\Backend\Model\Config\Backend\Filename</backend_model>
<comment>Logging from \Magento\Framework\Logger. File is located in {{base_dir}}/var/log</comment>
</field>
<field id="exception_file" translate="label comment" type="text" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Exceptions Log File Name</label>
<backend_model>Magento\Backend\Model\Config\Backend\Filename</backend_model>
<comment>Logging from \Magento\Framework\Logger. File is located in {{base_dir}}/var/log</comment>
</field>
</group>
<group id="js" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="1">
<label>JavaScript Settings</label>
<field id="merge_files" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Backend/i18n/de_DE.csv
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ Developer,Developer
"Translate, blocks and other output caches should be disabled for both frontend and admin inline translations.","Translate, blocks and other output caches should be disabled for both frontend and admin inline translations."
"Log Settings","Log Settings"
"System Log File Name","System Log File Name"
"Logging from \Magento\Framework\Logger. File is located in {{base_dir}}/var/log","Logging from \Magento\Framework\Logger. File is located in {{base_dir}}/var/log"
"Logging from \Psr\Log\LoggerInterface. File is located in {{base_dir}}/var/log","Logging from \Psr\Log\LoggerInterface. File is located in {{base_dir}}/var/log"
"Exceptions Log File Name","Exceptions Log File Name"
"JavaScript Settings","JavaScript Settings"
"Merge JavaScript Files","Merge JavaScript Files"
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Backend/i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ Developer,Developer
"Translate, blocks and other output caches should be disabled for both frontend and admin inline translations.","Translate, blocks and other output caches should be disabled for both frontend and admin inline translations."
"Log Settings","Log Settings"
"System Log File Name","System Log File Name"
"Logging from \Magento\Framework\Logger. File is located in {{base_dir}}/var/log","Logging from \Magento\Framework\Logger. File is located in {{base_dir}}/var/log"
"Logging from \Psr\Log\LoggerInterface. File is located in {{base_dir}}/var/log","Logging from \Psr\Log\LoggerInterface. File is located in {{base_dir}}/var/log"
"Exceptions Log File Name","Exceptions Log File Name"
"JavaScript Settings","JavaScript Settings"
"Merge JavaScript Files","Merge JavaScript Files"
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Backend/i18n/es_ES.csv
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ Developer,Developer
"Translate, blocks and other output caches should be disabled for both frontend and admin inline translations.","Translate, blocks and other output caches should be disabled for both frontend and admin inline translations."
"Log Settings","Log Settings"
"System Log File Name","System Log File Name"
"Logging from \Magento\Framework\Logger. File is located in {{base_dir}}/var/log","Logging from \Magento\Framework\Logger. File is located in {{base_dir}}/var/log"
"Logging from \Psr\Log\LoggerInterface. File is located in {{base_dir}}/var/log","Logging from \Psr\Log\LoggerInterface. File is located in {{base_dir}}/var/log"
"Exceptions Log File Name","Exceptions Log File Name"
"JavaScript Settings","JavaScript Settings"
"Merge JavaScript Files","Merge JavaScript Files"
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Backend/i18n/fr_FR.csv
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ Developer,Developer
"Translate, blocks and other output caches should be disabled for both frontend and admin inline translations.","Translate, blocks and other output caches should be disabled for both frontend and admin inline translations."
"Log Settings","Log Settings"
"System Log File Name","System Log File Name"
"Logging from \Magento\Framework\Logger. File is located in {{base_dir}}/var/log","Logging from \Magento\Framework\Logger. File is located in {{base_dir}}/var/log"
"Logging from \Psr\Log\LoggerInterface. File is located in {{base_dir}}/var/log","Logging from \Psr\Log\LoggerInterface. File is located in {{base_dir}}/var/log"
"Exceptions Log File Name","Exceptions Log File Name"
"JavaScript Settings","JavaScript Settings"
"Merge JavaScript Files","Merge JavaScript Files"
Expand Down
Loading

0 comments on commit 59f1a97

Please sign in to comment.