Last active
December 15, 2015 04:39
-
-
Save eftakhairul/5202780 to your computer and use it in GitHub Desktop.
Easy Debug
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
class Debug | |
{ | |
private $debug = true; | |
private $start_time = 0; | |
/** | |
* prints debug message | |
* @param type $message | |
*/ | |
public function debug($message) | |
{ | |
if (!$this->debug) | |
return; | |
if ($this->start_time == 0) { | |
$duration = 0; | |
} else { | |
$duration = round((time() - $this->start_time)); | |
} | |
echo '[DEBUG] ' . $message . ' ( Mem: ' . round(memory_get_usage() / 1048576, 2) . " MB, Time: $duration s )\n"; | |
$this->start_time = time(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment