Skip to content

Instantly share code, notes, and snippets.

@victordit
Last active July 5, 2017 09:51
Show Gist options
  • Save victordit/ef5b3b8f9c91c4040194 to your computer and use it in GitHub Desktop.
Save victordit/ef5b3b8f9c91c4040194 to your computer and use it in GitHub Desktop.
<?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