From c2e268ec43878f0204440600254065b68eb20a71 Mon Sep 17 00:00:00 2001 From: pitchum Date: Sat, 18 Jun 2022 16:40:21 +0200 Subject: [PATCH] =?UTF-8?q?Ajoute=20un=20logger=20sp=C3=A9cifique=20Chapri?= =?UTF-8?q?l?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + lib/Data/Filesystem.php | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/.gitignore b/.gitignore index 65ef7189..cfa7ef9b 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,4 @@ tst/ConfigurationCombinationsTest.php .c9 /.idea/ *.iml +paste.log diff --git a/lib/Data/Filesystem.php b/lib/Data/Filesystem.php index b2bc1eed..1feaf39c 100644 --- a/lib/Data/Filesystem.php +++ b/lib/Data/Filesystem.php @@ -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); + } }