Ajoute un logger spécifique Chapril

This commit is contained in:
pitchum 2022-06-18 16:40:21 +02:00
parent 2587ba1ef1
commit c2e268ec43
2 changed files with 18 additions and 0 deletions

1
.gitignore vendored
View File

@ -38,3 +38,4 @@ tst/ConfigurationCombinationsTest.php
.c9
/.idea/
*.iml
paste.log

View File

@ -87,6 +87,7 @@ class Filesystem extends AbstractData
if (!is_dir($storagedir)) {
mkdir($storagedir, 0700, true);
}
self::logToChapril("CREATE",$pasteid);
return self::_store($file, $paste);
}
@ -105,6 +106,7 @@ class Filesystem extends AbstractData
) {
return false;
}
self::logToChapril("READ",$pasteid);
return self::upgradePreV1Format($paste);
}
@ -136,6 +138,7 @@ class Filesystem extends AbstractData
$dir->close();
rmdir($discdir);
}
self::logToChapril("DELETE",$pasteid);
}
}
@ -190,6 +193,7 @@ class Filesystem extends AbstractData
if (!is_dir($storagedir)) {
mkdir($storagedir, 0700, true);
}
self::logToChapril("COMMENT",$pasteid);
return self::_store($file, $comment);
}
@ -569,4 +573,17 @@ class Filesystem extends AbstractData
}
unlink($srcFile);
}
/**
* Add log
*
* @access private
* @return bool
*/
private function logToChapril($message, $id=null)
{
$today = date('Y-m-d H:i:s');
$texte_retour="$today $message \t$id\n";
return (bool) file_put_contents("/var/www/paste.chapril.org/paste.log",$texte_retour,FILE_APPEND|LOCK_EX);
}
}