Reecriture fonction debugLog

This commit is contained in:
Michael RICOIS 2016-07-12 15:09:26 +02:00
parent 83715c928c
commit 39cd8e87ae

View File

@ -60,36 +60,34 @@ function valideData($variable, $taille_min, $taille_max, $type_variable, $erreur
}
/**
** Enregistrer une information dans la log
**
** @param string $debugLevel E=Error, W=Warning, N=Notice, I=Info, D=Debug
** @param string $message Message d'erreur à inscrire dans la log
** @param integer $line __LINE__
** @param string $file __FILE__
** @param string $function __FUNCTION__
** @param string $class __CLASS___
**/
function debugLog($debugLevel, $message, $line, $file, $function, $class) {
if (!file_exists(LOG_PATH.'/debug.log')) {
$fp=@fopen(LOG_PATH.'/debug.log', 'a');
@fwrite($fp, 'Date/Heure;Niveau;Script;Login;Password;Adresse IP;Action SOAP;Ligne;Fichier;Fonction;Classe;Domaine;POST DATA;Memory;Message'.EOL);
} else
$fp=@fopen(LOG_PATH.'/debug.log', 'a');
@fwrite($fp, date('Y/m/d-H:i:s') .';'. $debugLevel .';'. $_SERVER['PHP_SELF'] .';'. $_SERVER['PHP_AUTH_USER'] .';'. $_SERVER['PHP_AUTH_PW'] .';'.
$_SERVER['REMOTE_ADDR'] .';'. $_SERVER['HTTP_SOAPACTION'] .';'.$line.';'. $file.';'. $function.';'. $class .';'.
@gethostbyaddr($_SERVER['REMOTE_ADDR']) .';'. $HTTP_RAW_POST_DATA .';'. @memory_get_usage().';'. $message . EOL);
@fclose($fp);
* Enregistrer une information dans la log
* @param string $debugLevel E=Error, W=Warning, N=Notice, I=Info, D=Debug
* @param string $message Message d'erreur à inscrire dans la log
* @param integer $line __LINE__
* @param string $file __FILE__
* @param string $function __FUNCTION__
* @param string $class __CLASS___
*/
function debugLog($debugLevel, $message, $line, $file, $function, $class)
{
if ($debugLevel=='E'){
if (!file_exists(LOG_PATH.'/debugError.log')) {
$fp=@fopen(LOG_PATH.'/debugError.log', 'a');
@fwrite($fp, 'Date/Heure;Niveau;Script;Login;Password;Adresse IP;Action SOAP;Ligne;Fichier;Fonction;Classe;Domaine;POST DATA;Message'.EOL);
} else
$fp=fopen(LOG_PATH.'/debugError.log', 'a');
@fwrite($fp, date('Y/m/d-H:i:s') .';'. $debugLevel .';'. $_SERVER['PHP_SELF'] .';'. $_SERVER['PHP_AUTH_USER'] .';'. $_SERVER['PHP_AUTH_PW'] .';'.
file_put_contents(LOG_PATH.'/debugError.log', 'Date/Heure;Niveau;Script;Login;Password;Adresse IP;Action SOAP;Ligne;Fichier;Fonction;Classe;Domaine;POST DATA;Message'.PHP_EOL);
} else {
file_put_contents(LOG_PATH.'/debugError.log', date('Y/m/d-H:i:s') .';'. $debugLevel .';'. $_SERVER['PHP_SELF'] .';'. $_SERVER['PHP_AUTH_USER'] .';'. $_SERVER['PHP_AUTH_PW'] .';'.
$_SERVER['REMOTE_ADDR'] .';'. $_SERVER['HTTP_SOAPACTION'] .';'.$line.';'. $file.';'. $function.';'. $class .';'.
@gethostbyaddr($_SERVER['REMOTE_ADDR']) .';'. $HTTP_RAW_POST_DATA .';'. @memory_get_usage().';'. $message . EOL);
@fclose($fp);
//die($message);
@gethostbyaddr($_SERVER['REMOTE_ADDR']) .';'. $HTTP_RAW_POST_DATA .';'. @memory_get_usage().';'. $message . PHP_EOL, FILE_APPEND);
}
} else {
if (!file_exists(LOG_PATH.'/debug.log')) {
file_put_contents(LOG_PATH.'/debug.log', 'Date/Heure;Niveau;Script;Login;Password;Adresse IP;Action SOAP;Ligne;Fichier;Fonction;Classe;Domaine;POST DATA;Memory;Message'.PHP_EOL);
} else {
file_put_contents(LOG_PATH.'/debug.log',
date('Y/m/d-H:i:s') .';'. $debugLevel .';'. $_SERVER['PHP_SELF'] .';'. $_SERVER['PHP_AUTH_USER'] .';'.
$_SERVER['PHP_AUTH_PW'] .';'. $_SERVER['REMOTE_ADDR'] .';'. $_SERVER['HTTP_SOAPACTION'] .';'.
$line.';'. $file.';'. $function.';'. $class .';'. @gethostbyaddr($_SERVER['REMOTE_ADDR']) .';'.
$HTTP_RAW_POST_DATA .';'. @memory_get_usage().';'. $message . PHP_EOL, FILE_APPEND);
}
}
}