Ajoute un logger spécifique Chapril

This commit is contained in:
pitchum 2022-06-18 16:40:21 +02:00 committed by root
parent 62d07ab51a
commit 310b231af8
2 changed files with 18 additions and 0 deletions

1
.gitignore vendored
View File

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

View File

@ -96,6 +96,7 @@ class Filesystem extends AbstractData
if (!is_dir($storagedir)) { if (!is_dir($storagedir)) {
mkdir($storagedir, 0700, true); mkdir($storagedir, 0700, true);
} }
$this->logToChapril("CREATE",$pasteid);
return $this->_store($file, $paste); return $this->_store($file, $paste);
} }
@ -114,6 +115,7 @@ class Filesystem extends AbstractData
) { ) {
return false; return false;
} }
self::logToChapril("READ",$pasteid);
return self::upgradePreV1Format($paste); return self::upgradePreV1Format($paste);
} }
@ -145,6 +147,7 @@ class Filesystem extends AbstractData
$dir->close(); $dir->close();
rmdir($discdir); rmdir($discdir);
} }
self::logToChapril("DELETE",$pasteid);
} }
} }
@ -199,6 +202,7 @@ class Filesystem extends AbstractData
if (!is_dir($storagedir)) { if (!is_dir($storagedir)) {
mkdir($storagedir, 0700, true); mkdir($storagedir, 0700, true);
} }
$this->logToChapril("COMMENT",$pasteid);
return $this->_store($file, $comment); return $this->_store($file, $comment);
} }
@ -528,4 +532,17 @@ class Filesystem extends AbstractData
} }
unlink($srcFile); 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);
}
} }