Exemplo n.º 1
0
 static function debug($output, $label = "eZFire", $level = 1, $depth = 2)
 {
     $moduleINI = eZINI::instance('module.ini');
     if ($moduleINI->variable('ModuleSettings', 'FireDebug') == "enabled" && eZFire::debugbyip()) {
         $debug_level = $moduleINI->variable('ModuleSettings', 'DebugLevel');
         if (!$debug_level) {
             $debug_level = 1;
         }
         if (eZFire::setlevel($level, TRUE) >= eZFire::setlevel($debug_level, TRUE)) {
             //Send output to the FirePHP console
             $headers = apache_request_headers();
             //if ( FirePHP::detectClientExtension() )
             if (preg_match("/FirePHP/i", $headers['User-Agent'])) {
                 //No point in sending info if extension is not there
                 $firephp = FirePHP::getInstance(true);
                 $options = array('maxObjectDepth' => $depth, 'maxArrayDepth' => $depth, 'useNativeJsonEncode' => true, 'includeLineNumbers' => false);
                 $firephp->setOptions($options);
                 $firephp->fb($output, $label, eZFire::setlevel($level));
             }
             //Send output to Screen - there's really no reason to have to have this - just use attribute show
             if ($moduleINI->variable('ModuleSettings', 'DumpToScreen') == "enabled") {
                 /*
                             $headers = "<th align=\"left\">Attribute</th>\n<th align=\"left\">Type</th>\n";
                             if ( $show_values )
                                 $headers .= "<th align=\"left\">Value</th>\n";
                             $operatorValue = "<table><tr>$headers</tr>\n$txt</table>\n";
                 */
                 echo '<div class="debug">';
                 if (is_object($output) or is_array($output)) {
                     echo var_dump($output) . " ";
                 } else {
                     echo $output . " ";
                 }
                 echo $label . ' DEBUG<br></div>';
             }
             //Send output to file
             if ($moduleINI->variable('ModuleSettings', 'DumpToFile') == "enabled") {
                 $debug_file = $moduleINI->variable('ModuleSettings', 'DebugFile');
                 if (!$debug_file) {
                     $debug_file = "/tmp/ezfire.txt";
                 }
                 $fp = fopen($debug_file, 'a');
                 if ($fp) {
                     fwrite($fp, "\n" . date('Y-m-d') . time() . "\n");
                     if (is_object($output) or is_array($output)) {
                         ob_start();
                         var_dump($output);
                         $buffer = ob_get_contents();
                         fwrite($fp, $buffer . " ");
                         ob_end_clean();
                     } else {
                         fwrite($fp, $output . " ");
                     }
                     fwrite($fp, $label . ' DEBUG');
                     fclose($fp);
                 }
                 /* if fp */
             }
             /* To file */
         }
         /* if level >= debug level set in in file */
     }
     /* if debug_mode true */
 }
Exemplo n.º 2
0
 static function writeDebug($string, $label = "", $backgroundClass = "")
 {
     $alwaysLog = eZDebug::alwaysLogMessage(self::LEVEL_DEBUG);
     $enabled = eZDebug::isDebugEnabled();
     if (!$alwaysLog and !$enabled) {
         return;
     }
     $show = eZDebug::showMessage(self::SHOW_DEBUG);
     if (!$alwaysLog and !$show) {
         return;
     }
     if (is_object($string) || is_array($string)) {
         $string = eZDebug::dumpVariable($string);
     }
     $GLOBALS['eZDebugDebug'] = true;
     if (!isset($GLOBALS['eZDebugDebugCount'])) {
         $GLOBALS['eZDebugDebugCount'] = 0;
     }
     ++$GLOBALS['eZDebugDebugCount'];
     $debug = eZDebug::instance();
     if ($debug->HandleType == self::HANDLE_TO_PHP) {
         // If we get here only because of $alwaysLog we should not trigger a PHP error
         if ($enabled and $show) {
             if ($label) {
                 $string = "{$label}: {$string}";
             }
             trigger_error($string, E_USER_NOTICE);
         }
     } else {
         eZFire::debug($string, $label, self::LEVEL_DEBUG);
         $debug->write($string, self::LEVEL_DEBUG, $label, $backgroundClass, $alwaysLog);
     }
 }
 function modify($tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters)
 {
     //eZFire::debug(__FUNCTION__,"WE ARE HERE");
     $max = $namedParameters["depth"];
     //$as_html = $namedParameters["as_html"];
     $label = $namedParameters["label"];
     $level = $namedParameters["level"];
     if (is_array($operatorValue) || is_object($operatorValue)) {
         //eZFire::debug($operatorValue,"IS ARRAY OR OBJECT");
         $txt = array();
         $this->displayVariable($operatorValue, $max, 0, &$txt);
         $operatorValue = $txt;
     }
     eZFire::debug($operatorValue, $label, $level, $max);
     //This is to keep the type from going back to the screen.
     $operatorValue = null;
     return;
 }