MyXoops Forum

Aw:: XOOPS-Debug ohne XOOPS-Debug! [Script-Workshop] - myXOOPS German Support

frankblack

"myXOOPs"-Profi
Gepostet am:30.07.2009 16:20
frankblack
frankblack Offline (Show more)
"myXOOPs"-Profi
Posts: 747
Since: 19.04.2006
#8

Aw:: XOOPS-Debug ohne XOOPS-Debug!

Wer wissen will, welche Dateien mit include oder require eingebunden worden sind, muss folgenden Code in class/logger/render.php nach $ret=''; (Zeile 218) einfügen:

$this->addExtra'Included files'count get_included_files() ) . ' files' );

$included_files get_included_files();

foreach (
$included_files as $filename) {
    
$this->addExtra('Included file: '$filename);
}
... is gone with the wind ...

frankblack

"myXOOPs"-Profi
Gepostet am:30.07.2009 13:10
frankblack
frankblack Offline (Show more)
"myXOOPs"-Profi
Posts: 747
Since: 19.04.2006
#7

Aw:: XOOPS-Debug ohne XOOPS-Debug!

Na super! Ich habe doch tatsächlich beim Zusammenpacken ein paar Dateien übersehen. Sorry!

(Hoffentlich) Korrekte Datei ist angehängt.

Cool! Gerade gesehen: Fehler werden runter bis zu den kompilierten smarty-HTML-PHP-Dateien geloggt. Was beweist, dass smarty ziemlich nickelig ist. Meistens handelt es sich um nicht definierte Indizes von Variablen/Arrays.

Datei anhängen:


Link nur für registrierte Benutzer
... is gone with the wind ...

Advertisement

Gepostet am:0
Advertisement (Show more)
Posts: 0
Since: 0


Hier könnten Sie Ihre Anzeige aufgeben!
Bitte kontaktieren Sie uns, um mehr darüber zu erfahren.

frankblack

"myXOOPs"-Profi
Gepostet am:30.07.2009 08:49
frankblack
frankblack Offline (Show more)
"myXOOPs"-Profi
Posts: 747
Since: 19.04.2006
#6

Aw:: XOOPS-Debug ohne XOOPS-Debug!

Zitat:

WDC schrieb:
Hammer,

vielen Dank, habe es ausprobiert, und ich muss sagen, geil

Vielen Dank für die Mühe und das Du es mit uns teilst

Super Arbeit mein Guter


Merci! Debug mit FirePHP ist aber noch nicht fertig. Ich würde gerne noch alle Variablen und deren Inhalte mit ausgeben. Hatte fast geklappt, aber stellenweise wird mir bei manchen Variablen, besonders bei den GLOBALS, immer noch nur Array ausgegeben und ich weiß nicht, wie ich ALLE Inhalte bekomme, auch wenn sie mehrfach verschachtelt sind.

Vielleicht hat Alfred eine Idee? Blinkblink
... is gone with the wind ...

WDC

"myXOOPs"-Profi
Gepostet am:30.07.2009 00:22
WDC
WDC Offline (Show more)
"myXOOPs"-Profi
Posts: 637
Since: 27.06.2004
#5

Aw:: XOOPS-Debug ohne XOOPS-Debug!

Hammer,

vielen Dank, habe es ausprobiert, und ich muss sagen, geil

Vielen Dank für die Mühe und das Du es mit uns teilst

Super Arbeit mein Guter

frankblack

"myXOOPs"-Profi
Gepostet am:29.07.2009 23:58
frankblack
frankblack Offline (Show more)
"myXOOPs"-Profi
Posts: 747
Since: 19.04.2006
#4

Aw:: XOOPS-Debug ohne XOOPS-Debug!

So, ich habe jetzt mal ein kleines Paket geschnürt.

Firebug und FirePHP für Firefox installieren und laut Anleitung auf firephp.org einrichten (nur ein paar Klicks).

ZIP runterladen, entpacken und die Dateien / Ordner per FTP hochladen. Sicherheitshalber Dateien die überschrieben werden sollen, vorher sichern. Auch die Datenbank sichern, weil der Datenbank noch zwei Einträge hinzugefügt werden müssen.

Im Browser die Datei www.euredomain.com/adddebug.php ansurfen. Danach diese Datei unbedingt löschen.

Dann in der Administration die Voreinstellungen / Grundeinstellungen besuchen. Bei den Debug-Modi gibt es jetzt zwei weitere Möglichkeiten: FirePHP und FirePHP + Gast.

Letztere Möglichkeit erlaubt auch ein Debugging, wenn man nicht als User eingeloggt ist. Das ist aber eine Einstellung die eher für Entwickler interessant ist, die lokal entwickeln.

Die Installation und Betriebnahme der neuen Debug-Modi erfolgt auf eigenes Risiko!

Viel Erfolg!


Datei anhängen:


Link nur für registrierte Benutzer
... is gone with the wind ...

frankblack

"myXOOPs"-Profi
Gepostet am:29.07.2009 17:43
frankblack
frankblack Offline (Show more)
"myXOOPs"-Profi
Posts: 747
Since: 19.04.2006
#3

Aw:: XOOPS-Debug ohne XOOPS-Debug!

Fast vergessen: Der Ordner "FirePHPCore" muss mitsamt Inhalt in eure XOOPS-root.

Okay, ich habe gerade versucht auch den smarty-debug einzubauen und habe hierfür einen Code gefunden. Leider ist der Code etwas veraltet und die Debug-Infos werden nicht kollabiert angezeigt. Benutzung auf eigene Gefahr.

Schritt 1: class/template.php bearbeiten, sollte Zeile 56 sein, von
if ( $xoopsConfig['debug_mode'] == ) {

ändern in
if ( $xoopsConfig['debug_mode'] == ) {


Schritt 2: include/common.php bearbeiten, sollte Zeile 182 sein, von
if ( $xoopsConfig['debug_mode'] == || $xoopsConfig['debug_mode'] == ) {

ändern in
if ( $xoopsConfig['debug_mode'] == || $xoopsConfig['debug_mode'] == || $xoopsConfig['debug_mode'] == ) {


Schritt 3: class/smarty/internals/core.display_debug_console.php bearbeiten und komplett mit dem folgenden Code ersetzen
<?php
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */

/**
 * Smarty debug_console function plugin
 *
 * Type:     core<br>
 * Name:     display_debug_console<br>
 * Purpose:  display the javascript debug console window
 * @param array Format: null
 * @param Smarty
 */

if (!defined('XOOPS_ROOT_PATH')) die('XOOPS_ROOT_PATH not defined');
require_once 
XOOPS_ROOT_PATH.'/FirePHPCore/FirePHP.class.php';

function 
smarty_core_display_debug_console($params, &$smarty)
{
    
//get required debug variables
    
$assigned_vars $smarty->_tpl_vars;
    
ksort($assigned_vars);

    
$config_vars = array();
    if(@
is_array($smarty->_config[0])){
        
$config_vars $smarty->_config[0];
        
ksort($config_vars);
    }

    
$firephp FirePHP::getInstance(true);

    
$firephp->group('Smarty Debug Output');
    
/*Log template files*/
    
$firephp->group('included templates & config files (load time in seconds)');
    foreach( 
$smarty->_smarty_debug_info as $tml ){
        
$msg str_repeat('--'$tml['depth']);
        
$msg .= ( $tml['depth'] != ) ? '>' '';
        if (isset(
$tml['exec_time'])) $getthetime ' (' substr($tml['exec_time'], 07) . 's)';
        else 
$getthetime '';
        
$msg .= $tml['filename'] . $getthetime;
        
$firephp->log($msg);
    }
    
$firephp->groupEnd(); //end group 'included templates &...'


    /*Log assigned template variables*/
    
$firephp->group('assigned template variables');
    foreach( 
$assigned_vars as $key => $value ){
        
$firephp->log($value'{$' $key '}');
    }
    
$firephp->groupEnd(); //end group 'assigned template variables'


    /*Log assigned config file variables (outer template scope)*/
    
$firephp->group('assigned config file variables (outer template scope)');
    
/*Check if there is something in the config*/
    
if(!empty($config_vars)){
        foreach( 
$config_vars as $key => $value ){
            
$firephp->log($value'{#' $key '#}');
        }
    } else{
        
$firephp->log("No configuration values available");
    }
    
$firephp->groupEnd(); //end group 'assigned config file variables (outer template scope)'


    
$firephp->groupEnd(); //end group 'Smarty Debug Output'

}

/* vim: set expandtab: */

?>


Have fun!
... is gone with the wind ...

frankblack

"myXOOPs"-Profi
Gepostet am:29.07.2009 16:31
frankblack
frankblack Offline (Show more)
"myXOOPs"-Profi
Posts: 747
Since: 19.04.2006
#2

Aw:: XOOPS-Debug ohne XOOPS-Debug!

Ich habe mal einen Bildschirmschuss dazu angehängt.

Datei anhängen:



jpg  (0.00 KB)

... is gone with the wind ...

frankblack

"myXOOPs"-Profi
Gepostet am:29.07.2009 15:53
frankblack
frankblack Offline (Show more)
"myXOOPs"-Profi
Posts: 747
Since: 19.04.2006
#1

XOOPS-Debug ohne XOOPS-Debug!

Nachdem ich diesen Beitrag bereits auf xoops.org gepostet habe, kommen jetzt auch die deutschen User in den Genuss meines "Geistesblitzes".

Ich fand die XOOPS-internen Debugging-Funktionen immer etwas nervig, besonders wenn man (x)ajax zusätzlich genutzt hat. XOOPS-Debug und xajax schließt sich leider aus.

So bin ich auf die Idee gekommen FireBug + FirePHP (Addons für Firefox) einzusetzen. Ich habe die Datei class/logger/render.php umgeschrieben um die Ausgabe des Debug an FirePHP weierzuleiten. Diese Lösung ist meiner Meinung nach sehr flexibel.

Mit dieser Lösung kann man jede Art von debug-Hinweis setzen ohne echos zu bemühen die das Layout zerstören.

Beispiel:
$fb->log($thevariwanttodisplay);


Natürlich kann man render.php noch weiter adaptieren, um beispielsweise die Server-Variablen auszugeben etc.pp.

FirePHP gibt es HIER

Hier der Code für class/logger/render.php (hoffe der textsanitöter zerbrezelt das jetzt nicht):
<?php
/**
 * Xoops Logger renderer
 *
 * You may not change or alter any portion of this comment or credits
 * of supporting developers from this source code or any supporting source code
 * which is considered copyrighted (c) material of the original comment or credit authors.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * @copyright       The XOOPS Project http://sourceforge.net/projects/xoops/
 * @license         http://www.fsf.org/copyleft/gpl.html GNU public license
 * @package         kernel
 * @subpackage      logger
 * @since           2.3.0
 * @author          Skalpa Keo <skalpa@xoops.org>
 * @author          Taiwen Jiang <phppp@users.sourceforge.net>
 * @version         $Id: render.php 2633 2009-01-10 03:09:41Z phppp $
 *
 * @todo            Not well written, just keep as it is. Refactored in 3.0
 */

defined'XOOPS_ROOT_PATH' ) or die();
//ob_start();
global $xoopsUser;

if (
is_object($xoopsUser)) {
require_once 
XOOPS_ROOT_PATH.'/FirePHPCore/FirePHP.class.php';
$fb FirePHP::getInstance(true);
$ret '';

$this->addExtra'Included files'count get_included_files() ) . ' files' );
$memory 0;
if ( 
function_exists'memory_get_usage' ) ) {
    
$memory memory_get_usage() . ' bytes';
} else {
    
$os = isset( $_ENV['OS'] ) ? $_ENV['OS'] : $_SERVER['OS'];
    if ( 
strposstrtolower$os ), 'windows') !== false ) {
        
$out = array();
        
exec('tasklist /FI "PID eq ' getmypid() . '" /FO LIST'$out );
        
$memory substr$out[5], strpos$out[5], ':') + 1) . ' [Estimated]';
    }
}
if ( 
$memory ) {
    
$this->addExtra'Memory usage'$memory );
}

if ( empty(
$mode) || $mode == 'errors' ) {
    
$types = array(
        
E_USER_NOTICE => 'Notice',
        
E_USER_WARNING => 'Warning',
        
E_USER_ERROR => 'Error',
        
E_NOTICE => 'Notice',
        
E_WARNING => 'Warning',
        
E_STRICT => 'Strict',
    );
  
$fberrors = array();

    foreach ( 
$this->errors as $error ) {
        
$fberrorstype = isset( $types$error['errno'] ] ) ? $types$error['errno'] ] : 'Unknown';
        
$fberrors[] = array($fberrorstype.sprintf": %s in file %s line %s"$this->sanitizePath($error['errstr']), $this->sanitizePath($error['errfile']), $error['errline'] ));
    }
if (!empty(
$fberrors)) $fb->table('Errors'$fberrors);
}

if ( empty(
$mode) || $mode == 'queries' ) {
  
$fbqueries = array();

    
$pattern '/b' preg_quote($GLOBALS['xoopsDB']->prefix()) . '_/i';

    foreach (
$this->queries as $q) {
        
$sql preg_replace($pattern''$q['sql']);
        if (isset(
$q['error'])) {
            
$fbqueries[] = array(htmlentities($sql).' Error number: '.$q['errno'].' Error message: '.$q['error']);
        } else {
            
$fbqueries[] = array(htmlentities($sql));
        }
    }
    
$fbqueries[] = array('Total: '.count($this->queries).' queries');

$fb->table('Queries'$fbqueries);
}

if ( empty(
$mode) || $mode == 'blocks' ) {
  
$fbblocks = array();

    foreach (
$this->blocks as $b) {
        if (
$b['cached']) {
            
$fbblocks[] = array(htmlspecialchars($b['name']).': Cached (regenerates every '.intval($b['cachetime']).' seconds)');
        } else {
            
$fbblocks[] = array(htmlspecialchars($b['name']).': No Cache');
        }
    }
    
$fbblocks[] = array('Total: '.count($this->blocks).' blocks');

    if (
count($this->blocks) > 0$fb->table('Blocks'$fbblocks);
}

if ( empty(
$mode) || $mode == 'extra' ) {
    
$fbextra = array();

    foreach (
$this->extra as $ex) {
        
$fbextra[] = array(htmlspecialchars($ex['name']).': '.htmlspecialchars($ex['msg']));
    }

    
$fb->table('Extra'$fbextra);
}

if ( empty(
$mode) || $mode == 'timers' ) {
    
$fbtimers = array();

    foreach ( 
$this->logstart as $k => $v ) {
        
$fbtimers[] = array(htmlspecialchars($k).' took ' sprintf"%.03f"$this->dumpTime($k) ) . ' seconds to load.');
    }

    
$fb->table('Timers'$fbtimers);
}
}

?>


Die Ausgabe ist leider nicht formschön, aber besser als vorher.

Ich hoffe dieser Code kann irgendwem nützen?

Edit: ich habe noch eine Abfrage nach xoopsUser eingebaut, um den Debug vor Gästen zu verstecken.
... is gone with the wind ...
Diesen Thread durchsuchen:  1 Anonyme Benutzer

Aktuell aus dem Forum

Forum Thema Antworten Views Letzter Beitrag
Modulentwicklung New Xoops Xcreate Module 0 5326 26.11.2025 15:22
efkan Gehe zum letzten Beitrag
Modulentwicklung XOOPS Custom Field Module 1 1814 24.11.2025 11:21
Goffy Gehe zum letzten Beitrag