Development : new tools for debugging in the new class \Noalyss\Dbg (dbg.php);

This commit is contained in:
sparkyx 2022-10-16 23:09:43 +02:00
parent 64a7b20df7
commit 50dcb029ff
20 changed files with 154 additions and 86 deletions

View file

@ -31,6 +31,7 @@ if (file_exists("../include/config.inc.php") ) {
define ('ALLOWED',1); define ('ALLOWED',1);
define ('ALLOWED_ADMIN',1); define ('ALLOWED_ADMIN',1);
require_once '../include/constant.php'; require_once '../include/constant.php';
\Noalyss\Dbg::echo_file(__FILE__);
require_once NOALYSS_INCLUDE.'/admin_repo.inc.php'; require_once NOALYSS_INCLUDE.'/admin_repo.inc.php';
} else { } else {
// Redirect to install file , if this file exists then // Redirect to install file , if this file exists then

View file

@ -81,9 +81,9 @@ if ( DEBUGNOALYSS > 1 ) {
/** /**
* Debug Design * Debug Design
*/ */
debug_show_size(); \Noalyss\Dbg::display_size();
debug_show_request(); \Noalyss\Dbg::display_request();
debug_show_global(); \Noalyss\Dbg::display_global();
} //<--- if DEBUG } //<--- if DEBUG
$g_parameter=new Noalyss_Parameter_Folder($cn); $g_parameter=new Noalyss_Parameter_Folder($cn);

View file

@ -65,9 +65,9 @@ if ( DEBUGNOALYSS > 1 ) {
/** /**
* Debug Design * Debug Design
*/ */
debug_show_size(); \Noalyss\Dbg::display_size();
debug_show_request(); \Noalyss\Dbg::display_request();
debug_show_global(); \Noalyss\Dbg::display_global();
} //<--- if DEBUG } //<--- if DEBUG
$ac=new Database(); $ac=new Database();
$hi=new HttpInput(); $hi=new HttpInput();

View file

@ -23,7 +23,7 @@
*/ */
if ( ! defined ('ALLOWED')) { die (_('Non autorisé'));} if ( ! defined ('ALLOWED')) { die (_('Non autorisé'));}
if ( ! defined ('ALLOWED_ADMIN')) { die (_('Non autorisé'));} if ( ! defined ('ALLOWED_ADMIN')) { die (_('Non autorisé'));}
\Noalyss\Dbg::echo_file(__FILE__);
include_once NOALYSS_INCLUDE."/class/user.class.php"; include_once NOALYSS_INCLUDE."/class/user.class.php";
require_once NOALYSS_INCLUDE."/lib/user_common.php"; require_once NOALYSS_INCLUDE."/lib/user_common.php";
include_once NOALYSS_INCLUDE."/lib/ac_common.php"; include_once NOALYSS_INCLUDE."/lib/ac_common.php";

View file

@ -23,6 +23,7 @@
* \brief let you see the list of the connexion * \brief let you see the list of the connexion
*/ */
if ( !defined ('ALLOWED')) die('Forbidden'); if ( !defined ('ALLOWED')) die('Forbidden');
\Noalyss\Dbg::echo_file(__FILE__);
?> ?>
<DIV class="content"> <DIV class="content">
<span class="notice"><?=_("100 dernières connexions")?></span> <span class="notice"><?=_("100 dernières connexions")?></span>

View file

@ -28,7 +28,7 @@
*/ */
if (!defined('ALLOWED')) if (!defined('ALLOWED'))
die('Appel direct ne sont pas permis'); die('Appel direct ne sont pas permis');
if ( DEBUGNOALYSS > 1 ) { echo __FILE__;} NoalyssDbg::echo_file(__FILE__);
global $http; global $http;
$str_dossier=Dossier::get(); $str_dossier=Dossier::get();

View file

@ -292,7 +292,7 @@ class Dossier
} }
/** /**
* connect to folder and give to admin. the profile Admin(builtin) * @brief connect to folder and give to admin. the profile Admin(builtin)
* @param int $p_id dossier::id() * @param int $p_id dossier::id()
*/ */
static function synchro_admin($p_id) static function synchro_admin($p_id)
@ -331,7 +331,7 @@ class Dossier
} }
} }
/** /**
* Upgrade check if the folder ACCOUNT_REPOSITORY needs to be upgrade thanks the variable DBVERSIONREPO * @brief Upgrade check if the folder ACCOUNT_REPOSITORY needs to be upgrade thanks the variable DBVERSIONREPO
* and run all the SQL script named ac-upgradeX.sql from the folder noalyss/include/sql/patch * and run all the SQL script named ac-upgradeX.sql from the folder noalyss/include/sql/patch
* until X equal DBVERSIONREPO-1 * until X equal DBVERSIONREPO-1
* After it will call the function apply_patch, remove_inexistant_user and clean_orphan_log for each folder * After it will call the function apply_patch, remove_inexistant_user and clean_orphan_log for each folder

View file

@ -40,6 +40,7 @@ $g_template_dir = $dirname . "/template";
if (file_exists($dirname . '/config.inc.php')) require_once $dirname . '/config.inc.php'; if (file_exists($dirname . '/config.inc.php')) require_once $dirname . '/config.inc.php';
if (!defined("NOALYSS_HOME")) define("NOALYSS_HOME", dirname($dirname) . "/html"); if (!defined("NOALYSS_HOME")) define("NOALYSS_HOME", dirname($dirname) . "/html");
if (!defined("NOALYSS_BASE")) define("NOALYSS_BASE", dirname($dirname) );
if (!defined("NOALYSS_PLUGIN")) define("NOALYSS_PLUGIN", $g_ext_dir); if (!defined("NOALYSS_PLUGIN")) define("NOALYSS_PLUGIN", $g_ext_dir);
if (!defined("NOALYSS_INCLUDE")) define("NOALYSS_INCLUDE", $g_include_dir); if (!defined("NOALYSS_INCLUDE")) define("NOALYSS_INCLUDE", $g_include_dir);
if (!defined("NOALYSS_TEMPLATE")) define("NOALYSS_TEMPLATE", $g_template_dir); if (!defined("NOALYSS_TEMPLATE")) define("NOALYSS_TEMPLATE", $g_template_dir);
@ -360,6 +361,7 @@ if (!defined("DEFAULT_SERVER_VIDEO_CONF")) {
function noalyss_class_autoloader($class) function noalyss_class_autoloader($class)
{ {
$class = strtolower($class); $class = strtolower($class);
foreach (array("class","lib","database") as $path) { foreach (array("class","lib","database") as $path) {
if ( file_exists(NOALYSS_INCLUDE.'/'.$path.'/'.$class.'.class.php')) { if ( file_exists(NOALYSS_INCLUDE.'/'.$path.'/'.$class.'.class.php')) {
require_once NOALYSS_INCLUDE.'/'.$path.'/'.$class.'.class.php'; require_once NOALYSS_INCLUDE.'/'.$path.'/'.$class.'.class.php';
@ -385,7 +387,8 @@ function noalyss_class_autoloader($class)
"ismallbutton" => "lib/ibutton.class.php", "ismallbutton" => "lib/ibutton.class.php",
"inputswitch" => "lib/input_switch.class.php", "inputswitch" => "lib/input_switch.class.php",
"noalyss\mobile" => "class/mobile.class.php", "noalyss\mobile" => "class/mobile.class.php",
"htmlinput" => "lib/html_input.class.php" "htmlinput" => "lib/html_input.class.php",
"noalyss\dbg"=>"lib/dbg.php"
); );
if (isset ($aClass[$class])) { if (isset ($aClass[$class])) {
require_once NOALYSS_INCLUDE . "/" . $aClass[$class]; require_once NOALYSS_INCLUDE . "/" . $aClass[$class];

View file

@ -168,13 +168,10 @@ function nbm($p_number,$p_dec = 2)
function echo_error($p_log, $p_line="", $p_message="") function echo_error($p_log, $p_line="", $p_message="")
{ {
echo "ERREUR :" . $p_log . " " . $p_line . " " . $p_message; $msg="ERREUR :" . $p_log . " " . $p_line . " " . $p_message;
$fdebug = fopen($_ENV['TMP'] . DIRECTORY_SEPARATOR . "noalyss_error.log", "a+"); echo $msg;
if ($fdebug != null) syslog(LOG_ERR,$msg);
{
fwrite($fdebug, date("Ymd H:i:s") . $p_log . " " . $p_line . " " . $p_message . "\n");
fclose($fdebug);
}
} }
/** /**
@ -1179,11 +1176,7 @@ function display_menu($p_menuid)
$array=compute_variable($file[0]['me_parameter']); $array=compute_variable($file[0]['me_parameter']);
put_global($array); put_global($array);
} }
if ( DEBUGNOALYSS == 2) \Noalyss\Dbg::echo_var(1,$file[0]['me_file']." ".$file[0]['me_parameter']);
{
echo $file[0]['me_file']," param : ",$file[0]['me_parameter'] ;
}
/* /*
* Log the file we input to put in the folder test-noalyss for replaying it * Log the file we input to put in the folder test-noalyss for replaying it
*/ */
@ -1683,58 +1676,5 @@ function linkTo($p_url)
return $p_url; return $p_url;
} }
} }
function debug_show_size()
{
echo <<<EOF
<div class="d-block d-sm-none " style="background-color:lightblue">Xtra Small</div>
<div class="d-none d-sm-block d-md-none d-lg-none d-xl-none " style="background-color:red">Small</div>
<div class="d-none d-md-block d-lg-none " style="background-color:orangered">Medium</div>
<div class="d-none d-lg-block d-xl-none " style="background-color:orange">Large</div>
<div class="d-none d-xl-block " style="background-color:wheat">X Large</div>
EOF;
}
/**
* @brief for development , show request (POST, GET)
* @return void
*/
function debug_show_request() {
$id=uniqid("debug");
$title=\HtmlInput::title_box(_("REQUEST"),$id,"hide");
?>
<div class=" col-10 inner_box" style="display:none" id="<?=$id?>">
<?=$title?>
<h2 style="margin-top:100px"> Memory Usage
<?php echo round(memory_get_usage()/1024.0,2) . " kb \n"; ?>
</h2>
$_POST
<pre><?php echo print_r($_POST)?></pre>
$_GET
<pre><?=print_r($_GET)?></pre>
$_REQUEST
<pre><?=print_r($_REQUEST)?></pre>
<?=\HtmlInput::button_hide($id)?>
</div>
<input type="button" onclick="document.getElementById('<?=$id?>').show();" value="Show request">
<?php
}
/**
* @brief for development , show GLOBAL and SESSION
* @return void
*/
function debug_show_global() {
$id=uniqid("debug");
$title=\HtmlInput::title_box(_("GLOBALS"),$id,"hide");
?>
<div class=" col-10 inner_box" style="display:none" id="<?=$id?>">
<?=$title?>
$GLOBALS
<pre><?=print_r($GLOBALS)?></pre>
<?=\HtmlInput::button_hide($id)?>
</div>
<input type="button" onclick="document.getElementById('<?=$id?>').show();" value="Show session">
<?php
}

122
include/lib/dbg.php Normal file
View file

@ -0,0 +1,122 @@
<?php
namespace Noalyss;
class Dbg
{
public static function echo_var($n_level, $msg)
{
if (DEBUGNOALYSS > $n_level) {
echo '<span style="font-size:12px;color:orangered">';
$type = gettype($msg);
if (in_array($type, ["string", "integer", "double"])) {
echo $msg;
} else {
echo "<pre>DBG";
var_export($msg);
echo '</pre>';
}
echo '</span>';
}
}
public static function echo_file($msg)
{
if (DEBUGNOALYSS > 1) {
echo '<span style="font-size:12px;color:brown">';
echo "[FILE: $msg]";
echo '</span>';
}
}
static function display_size()
{
echo <<<EOF
<div class="d-block d-sm-none " style="background-color:lightblue">Xtra Small</div>
<div class="d-none d-sm-block d-md-none d-lg-none d-xl-none " style="background-color:red">Small</div>
<div class="d-none d-md-block d-lg-none " style="background-color:orangered">Medium</div>
<div class="d-none d-lg-block d-xl-none " style="background-color:orange">Large</div>
<div class="d-none d-xl-block " style="background-color:wheat">X Large</div>
EOF;
}
/**
* @brief for development , show request (POST, GET)
* @return void
*/
static function display_request()
{
$id = uniqid("debug");
$title = \HtmlInput::title_box(_("REQUEST"), $id, "hide");
?>
<div class=" col-10 inner_box" style="display:none" id="<?= $id ?>">
<?= $title ?>
<h2 style="margin-top:100px"> Memory Usage
<?php echo round(memory_get_usage() / 1024.0, 2) . " kb \n"; ?>
</h2>
$_POST
<pre><?php echo print_r($_POST) ?></pre>
$_GET
<pre><?= print_r($_GET) ?></pre>
$_REQUEST
<pre><?= print_r($_REQUEST) ?></pre>
<?= \HtmlInput::button_hide($id) ?>
</div>
<input type="button" onclick="document.getElementById('<?= $id ?>').show();" value="Show request">
<?php
}
/**
* @brief for development , show GLOBAL and SESSION
* @return void
*/
static function display_global()
{
$id = uniqid("debug");
$title = \HtmlInput::title_box(_("GLOBALS"), $id, "hide");
?>
<div class=" col-10 inner_box" style="display:none" id="<?= $id ?>">
<?= $title ?>
$GLOBALS
<pre><?= print_r($GLOBALS) ?></pre>
<?= \HtmlInput::button_hide($id) ?>
</div>
<input type="button" onclick="document.getElementById('<?= $id ?>').show();" value="Show session">
<?php
}
/**
* @brief Show a icon to display large information on demand, when you click it , the content will be showned
* @param string $p_title title of the dialog box
* @param mixed $msg var_export of the msg
* @return string HTML to display
*/
public static function hidden_info($p_title,$msg)
{
$id=uniqid("debug");
$title=\HtmlInput::title_box($p_title,"$id"."_infodiv","hide");
$content=var_export($msg,true);
$button_close=\HtmlInput::button_hide("$id"."_infodiv");
$r=<<<EOF
<div id="{$id}_infodiv" style="display: none;background:rgba(234, 221, 114, 0.66);color:black;font-size:80%;width:auto;">
{$title}
<div>
<pre>
{$content}
</pre>
</div>
{$button_close}
</div>
<a href="javascript:void(0)" onclick="$('{$id}_infodiv').show()">&#128374;</a>
EOF;
return $r;
}
}
?>

View file

@ -27,6 +27,7 @@
* *
*/ */
if ( !defined ('ALLOWED')) die('Forbidden'); if ( !defined ('ALLOWED')) die('Forbidden');
\Noalyss\Dbg::echo_file(__FILE__);
$http=new HttpInput(); $http=new HttpInput();
$sa = $http->request("sa", "string", 'list'); $sa = $http->request("sa", "string", 'list');
if (isset($_POST['upd']) && if (isset($_POST['upd']) &&

View file

@ -19,6 +19,7 @@
// Copyright Author Dany De Bontridder danydb@aevalys.eu // Copyright Author Dany De Bontridder danydb@aevalys.eu
if ( !defined ('ALLOWED')) die('Forbidden'); if ( !defined ('ALLOWED')) die('Forbidden');
\Noalyss\Dbg::echo_file(__FILE__);
$http=new HttpInput(); $http=new HttpInput();
/*!\file /*!\file
* \brief restaure a database * \brief restaure a database

View file

@ -21,7 +21,7 @@
if (!defined('ALLOWED')) if (!defined('ALLOWED'))
die('Appel direct ne sont pas permis'); die('Appel direct ne sont pas permis');
if (DEBUGNOALYSS>1) { echo __FILE__;} \Noalyss\Dbg::echo_file(__FILE__);
/** /**
* @file * @file
* @brief display supplemental information to save when entering an operation of * @brief display supplemental information to save when entering an operation of

View file

@ -34,10 +34,11 @@ if (!defined('ALLOWED'))
* - $a_option.ap_id (-1 if option for this contact doesn't exist) * - $a_option.ap_id (-1 if option for this contact doesn't exist)
* @see Card_Multiple * @see Card_Multiple
*/ */
\Noalyss\Dbg::echo_file(__FILE__);
?> ?>
<h3 class="info" style="margin:1px"> <h3 class="info" style="margin:1px">
<?=$aIdentity['name']." ".$aIdentity['first_name']." ".$aIdentity['qcode']?> <?=$aIdentity['name']." ".$aIdentity['first_name']." ".$aIdentity['qcode']?>
</h2> </h3>
<form method="POST" onsubmit="save_linked_card_option(this);return false"> <form method="POST" onsubmit="save_linked_card_option(this);return false">
<input type="hidden" name="op" value="card"> <input type="hidden" name="op" value="card">
<input type="hidden" name="op2" value="save_card_option"> <input type="hidden" name="op2" value="save_card_option">

View file

@ -25,10 +25,7 @@ if (!defined('ALLOWED'))
* @file * @file
* @brief show the mobile menu * @brief show the mobile menu
*/ */
if (DEBUGNOALYSS>1) \Noalyss\Dbg::dbgecho_file(__FILE__);
{
echo __FILE__;
};
?> ?>
<img src="<?=NOALYSS_URL?>/image/logo9000.png" width="100%" style="position:absolute;top:0px;left:0px;z-index:-1;opacity: 11%"> <img src="<?=NOALYSS_URL?>/image/logo9000.png" width="100%" style="position:absolute;top:0px;left:0px;z-index:-1;opacity: 11%">
<div id="mobile_module" > <div id="mobile_module" >

View file

@ -21,7 +21,7 @@
if (!defined('ALLOWED')) die('Appel direct ne sont pas permis'); if (!defined('ALLOWED')) die('Appel direct ne sont pas permis');
if ( ! defined ('ALLOWED_ADMIN')) { die (_('Non autorisé'));} if ( ! defined ('ALLOWED_ADMIN')) { die (_('Non autorisé'));}
\Noalyss\Dbg::echo_file(__FILE__);
global $version_noalyss; global $version_noalyss;
/** /**
* @file * @file

View file

@ -25,7 +25,7 @@ if (!defined('ALLOWED_ADMIN'))
die(_('Non autorisé')); die(_('Non autorisé'));
} }
\Noalyss\Dbg::echo_file(__FILE__);
/** /**
* @file * @file

View file

@ -24,7 +24,7 @@ if (!defined('ALLOWED_ADMIN'))
{ {
die(_('Non autorisé')); die(_('Non autorisé'));
} }
\Noalyss\Dbg::echo_file(__FILE__);
$package_repository=new Package_Repository(); $package_repository=new Package_Repository();
$xml=$package_repository->getContent(); $xml=$package_repository->getContent();

View file

@ -25,7 +25,7 @@
*/ */
if (!defined('ALLOWED')) die('Appel direct ne sont pas permis'); if (!defined('ALLOWED')) die('Appel direct ne sont pas permis');
if ( ! defined ('ALLOWED_ADMIN')) { die (_('Non autorisé'));} if ( ! defined ('ALLOWED_ADMIN')) { die (_('Non autorisé'));}
\Noalyss\Dbg::echo_file(__FILE__);
$http=new HttpInput(); $http=new HttpInput();
$menu=array( $menu=array(

View file

@ -28,6 +28,7 @@ if ( !defined ('ALLOWED')) die('Forbidden');
*/ */
$http=new HttpInput(); $http=new HttpInput();
echo '<div class="content" >'; echo '<div class="content" >';
\Noalyss\Dbg::echo_file(__FILE__);
/******************************************************/ /******************************************************/
// Add user // Add user
/******************************************************/ /******************************************************/