Last active
July 5, 2017 09:51
-
-
Save victordit/ef5b3b8f9c91c4040194 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
const LOG = 'my.log'; | |
/** | |
* @return void | |
* @param $var The variable passed | |
* @param string $label | |
* @param boolean $backtrace | |
*/ | |
public function log($label,$var=null,$backtrace = false) | |
{ | |
if($backtrace){ | |
$ouput = str_replace(array('<pre>','</pre>'),'',Varien_Debug::backtrace(true, true)); | |
}else{ | |
$d= debug_backtrace(); | |
$level = 0; | |
$file = !isset($d[$level])?'':$d[$level]['file']; | |
$line = !isset($d[$level])?'':$d[$level]['line']; | |
$infoline = $file.' - '.$line.': '; | |
if($var){ | |
$message = $infoline.$label.': '; | |
$iouput = Zend_Debug::dump($var,$message,false); | |
$ouput = htmlspecialchars_decode(str_replace(array('<pre>','</pre>'),'',$iouput)); | |
}else{ | |
$ouput = $infoline.$label; | |
} | |
} | |
Mage::log($ouput, null, self::LOG); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment