Created
November 20, 2016 11:46
-
-
Save victordit/5ed3acaa90ef5eedb00396ecddacb47b 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 | |
/** | |
* @return void | |
* @param $var The variable passed | |
* @param string $module The name of module | |
* @param integer limit The limit for each | |
*/ | |
public function log($var,$module,$limit =2) | |
{ | |
$d= debug_backtrace(); | |
ob_start(); | |
$message="debug_backtrace:"; | |
foreach ($d as $level => $infoline) { | |
$file = $infoline['file']; | |
$line = $infoline['line']; | |
$infoline = "level ".$level.": ".$file. "- ".$line.";"; | |
$message.= $infoline; | |
if($level>$limit){ | |
break; | |
} | |
} | |
echo $message; | |
var_dump($var); | |
$debug_backtrace = ob_get_clean(); | |
\Drupal::logger($module)->debug('@'.$module.'Log: '.$debug_backtrace); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment