Last active
May 18, 2017 15:33
-
-
Save victordit/e22a3654112a16574c3a7751c131aea3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
/** | |
* @return void | |
* @param $var The variable passed | |
* @param string $label | |
* @param integer limit The limit for each | |
* @param string $path | |
*/ | |
public function log($var,$label=null,$limit =2,$path = null) | |
{ | |
if(!$path){ | |
$path = "/var/log/default.log"; | |
} | |
$d= debug_backtrace(); | |
ob_start(); | |
$message="debug_backtrace:"; | |
foreach ($d as $level => $infoline) { | |
$file = isset($infoline['file'])?$infoline['file']:''; | |
$line = isset($infoline['line'])?$infoline['line']:''; | |
$infoline = " level ".$level.": ".$file. "- ".$line; | |
$message.= $infoline.PHP_EOL; | |
if($level>$limit){ | |
break; | |
} | |
} | |
$message.= " ".$label.": "; | |
echo $message.PHP_EOL; | |
var_dump($var); | |
$debug_backtrace = ob_get_clean(); | |
error_log($debug_backtrace,3,$path) ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment