diff --git a/site/app_model.php b/site/app_model.php index 4f4d9ed..067ab83 100644 --- a/site/app_model.php +++ b/site/app_model.php @@ -45,6 +45,9 @@ class AppModel extends Model { // Default Log Level, if not specified at the function level var $default_log_level = 1; + // Class specific log levels + var $class_log_level = array('Model' => 5); + // Function specific log levels var $function_log_level = array(); @@ -55,6 +58,17 @@ class AppModel extends Model { var $max_log_level; + // REVISIT : 20090730 + // Why is this constructor crashing? + // Clearly it's in some sort of infinite + // loop, but it seems the correct way + // to have a constructor call the parent... + +/* function __construct() { */ +/* parent::__construct(); */ +/* $this->prClassLevel(5, 'Model'); */ +/* } */ + /************************************************************************** ************************************************************************** ************************************************************************** @@ -62,12 +76,24 @@ class AppModel extends Model { * - Prints out debug information, if the log level allows */ - function prFunctionLevel($level) { + function prClassLevel($level, $class = null) { $trace = debug_backtrace(false); $caller = array_shift($trace); $caller = array_shift($trace); - $function = $caller['function']; - $this->function_log_level[$function] = $level; + if (empty($class)) + $class = $caller['class']; + $this->class_log_level[$class] = $level; + } + + function prFunctionLevel($level, $function = null, $class = null) { + $trace = debug_backtrace(false); + $caller = array_shift($trace); + $caller = array_shift($trace); + if (empty($class)) + $class = $caller['class']; + if (empty($function)) + $function = $caller['function']; + $this->function_log_level["{$class}-{$function}"] = $level; } function _pr($level, $mixed, $checkpoint = null) { @@ -94,8 +120,10 @@ class AppModel extends Model { //$class = $this->name; // Adjust the log level from default, if necessary - if (isset($this->function_log_level[$function])) - $log_level = $this->function_log_level[$function]; + if (isset($this->class_log_level[$class])) + $log_level = $this->class_log_level[$class]; + if (isset($this->function_log_level["{$class}-{$function}"])) + $log_level = $this->function_log_level["{$class}-{$function}"]; if (isset($this->min_log_level)) $log_level = max($log_level, $this->min_log_level); if (isset($this->max_log_level)) @@ -116,6 +144,7 @@ class AppModel extends Model { echo '
'; echo '' . substr(str_replace(ROOT, '', $file), 1) . ''; echo ' (line ' . $line . ')'; + echo ' : level-' . $level; echo '
' . "\n"; pr(array("{$class}::{$function}()" => $mixed), false, false);