Skip to content

Instantly share code, notes, and snippets.

@cam-gists
Created September 11, 2012 05:41
Show Gist options
  • Save cam-gists/3696216 to your computer and use it in GitHub Desktop.
Save cam-gists/3696216 to your computer and use it in GitHub Desktop.
ChromePHP: Extend Chrome PHP for DRY Debug
<?php
/**
* Base Class
* Extends ChromPhp to allow for Rapid Debugging based on needs
*/
class Base extends ChromePhp
{
public function __construct()
{
if(DEBUG === TRUE){
parent::log(__CLASS__ . ' Class constructed - File: ' . __FILE__ . ' - Line: '. __LINE__ );
}
}
/**
* log determines debug settings to log errors and msgs as needed
*/
public static function log($msg, $severity){
if(DEBUG === 'VERBOSE'){
switch ($severity) {
case 'log':
parent::log($msg);
break;
case 'error':
parent::error($msg);
break;
case 'warn':
parent::warn($msg);
break;
}
}elseif(DEBUG === 'ERRORS_ONLY'){
switch ($severity) {
case 'error':
parent::error($msg);
break;
case 'warn':
parent::warn($msg);
break;
}
}elseif(DEBUG === 'FALSE'){
// Log Nothing
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment