Skip to content

Instantly share code, notes, and snippets.

@berliozd
Last active March 4, 2020 10:42
Show Gist options
  • Select an option

  • Save berliozd/d60bedc378c15800891d335ba1c15fb4 to your computer and use it in GitHub Desktop.

Select an option

Save berliozd/d60bedc378c15800891d335ba1c15fb4 to your computer and use it in GitHub Desktop.
<?php
/**
* @param $str
*/
private function log($str) {
$str = 'CLASS : ' . str_pad(__CLASS__, 50, ' ')
. ' - LINE : ' . str_pad(debug_backtrace()[0]['line'], 4, ' ')
. ' - FUNCTION : ' . str_pad(debug_backtrace()[1]['function'] , 15, ' ')
. ' - STR : ' . $str;
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
/** @var \Magento\Framework\Filesystem\DirectoryList $directory */
$directory = $objectManager->get('\Magento\Framework\Filesystem\DirectoryList');
$rootPath = $directory->getPath(\Magento\Framework\App\Filesystem\DirectoryList::VAR_DIR);
$logger = new \Zend\Log\Logger();
$writer = new \Zend\Log\Writer\Stream($rootPath . '/log/zendlog.log');
$logger->addWriter($writer);
$logger->debug($str);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment