Skip to content
Snippets Groups Projects
Commit 7f2dbacb authored by Laurent's avatar Laurent
Browse files

hotline #55142 inject Cata_Log in cosmogramme integration phase

parent a60e7f8d
Branches
Tags
2 merge requests!2334Master,!2133Hotline#55142 1 dtouch
Pipeline #1301 passed with stage
in 12 minutes and 22 seconds
......@@ -85,8 +85,7 @@ class Class_log
// ----------------------------------------------------------------
// Ecrire
// ----------------------------------------------------------------
public function ecrire($texte)
{
public function ecrire($texte) {
global $mode_cron;
fwrite($this->fic, $texte ."\n");
if($this->afficher == false) return false;
......@@ -153,8 +152,7 @@ class Class_log
// ----------------------------------------------------------------
// Afficher le contenu du log mode texte
// ----------------------------------------------------------------
public function afficher($log)
{
public function afficher($log) {
if($log == "") $log = $this->typeLog . "_" . dateDuJour(0) .".log";
if( !fileSize($this->path.$log))
{
......@@ -169,86 +167,9 @@ class Class_log
}
fclose($fic);
}
// ----------------------------------------------------------------
// Afficher le contenu du log en mode tableau
// ----------------------------------------------------------------
public function afficherTableau($log,$arg_bib="",$arg_type_erreur="")
{
if($log == "") $log = $this->typeLog . "_" . dateDuJour(0) .".log";
if( !fileSize($this->path.$log))
{
print("Ce fichier log est vide.");
return false;
}
// Entete du tableau
print('<table class="blank" cellspacing="0"><tr>');
foreach($this->entete as $col) print('<th class="blank">'.$col.'</th>');
print('</tr>');
// Parser les lignes
$fic=fopen($this->path.$log,"r");
while (!feof($fic))
{
$buffer = fgets($fic, 4096);
$data=explode(chr(9),$buffer);
// selection en mode detail
if($arg_bib and trim($data[1]) != $arg_bib) continue;
if($arg_type_erreur and trim($data[3]) != $arg_type_erreur) continue;
// Afficher ligne
$nb++;
if($nb > 2000) break;
if($data[0])
{
print('<tr>');
$prem=true;
foreach($data as $col)
{
if($prem==true)
{
$nom_fic="notice".substr($log,strlen($this->typeLog));
$col=rendUrlImg("loupe.png", "analyse_afficher_notice.php","mode=LOG&adresse=".$col."&fichier=".$nom_fic);
$prem=false;
}
if(!trim($col)) $col="&nbsp;";
print('<td class="blank">'.$col.'</td>');
}
print('</tr>');
}
}
fclose($fic);
print('</table>');
if($nb > 2000) print('<h3>Arrêt de l\'affichage à 2000 lignes</h3>');
}
// ----------------------------------------------------------------
// rend le contenu du log en mode Synthese par bibliotheques
// ----------------------------------------------------------------
public function getTableauSynthese($log)
{
if($log == "") $log = $this->typeLog . "_" . dateDuJour(0) .".log";
if(!fileSize($this->path.$log)) return false;
// Parser les lignes
$fic=fopen($this->path.$log,"r");
while (!feof($fic))
{
$buffer = fgets($fic, 4096);
$data=explode(chr(9),$buffer);
if($data[0])
{
$bib=$data[1];
$erreur=trim($data[3]);
$table[$bib][$this->typeLog][$erreur]++;
}
}
fclose($fic);
return $table;
}
// ----------------------------------------------------------------
// Fermeture
// ----------------------------------------------------------------
public function close()
{
public function close() {
fclose($this->fic);
}
......
......@@ -20,7 +20,23 @@
*/
function startIntegrationPhase($name) {
global $chrono, $chrono_fichier, $chrono100notices, $phase, $phase_data, $mode_cron, $reprise, $log, $compteur;
global
$chrono,
$chrono_fichier,
$chrono100notices,
$phase,
$phase_data,
$mode_cron,
$reprise,
$log,
$log_warning,
$log_error,
$compteur;
$logs = (new Class_Cata_Log())
->addDefaultTarget($log)
->addTarget('error', $log_error)
->addTarget('warning', $log_warning);
$integration_class_name = 'Class_Cosmogramme_Integration_Phase'.ucfirst($name);
......@@ -37,7 +53,7 @@ function startIntegrationPhase($name) {
$requested_phase = new $integration_class_name($current_phase,
$log,
$logs,
$current_chrono);
$new_phase = $requested_phase->run();
......
......@@ -77,8 +77,11 @@ class Class_Cata_Log {
if (!is_array($targets))
$targets = [$targets];
return array_intersect_key($this->_targets,
array_combine($targets, $targets));
$loggers = array_intersect_key($this->_targets,
array_combine($targets, $targets));
return $loggers
? $loggers
: [$this->_targets[static::DEFAULT_TARGET]];
}
}
?>
\ No newline at end of file
......@@ -54,7 +54,8 @@ class Class_Cata_LogTest extends ModelTestCase {
->addSuccess('250g Sugar')
->addSuccess('250g Butter')
->addError('Not enough Butter', 'default')
->addError('Go buy butter', '*');
->addError('Go buy butter', '*')
->ecrire('Then eat', 'nowhere');
}
......@@ -67,7 +68,8 @@ class Class_Cata_LogTest extends ModelTestCase {
'250g Sugar',
'250g Butter',
'Not enough Butter',
'Go buy butter']],
'Go buy butter',
'Then eat']],
['error', ['Trying 2.0 version',
'1.0 was buggy',
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment