Parcourir la source

Log compatible multi-utilisateur

Contribue à https://github.com/marienfressinaud/FreshRSS/issues/126.
Il faudra restaurer la gestion du cache HTTP pour les logs
Alexandre Alapetite il y a 12 ans
Parent
commit
3cc073f2d1
4 fichiers modifiés avec 6 ajouts et 9 suppressions
  1. 2 2
      app/Controllers/indexController.php
  2. 2 4
      app/Models/LogDAO.php
  3. 2 2
      lib/Minz/Log.php
  4. 0 1
      p/i/index.php

+ 2 - 2
app/Controllers/indexController.php

@@ -218,10 +218,10 @@ class FreshRSS_index_Controller extends Minz_ActionController {
 		Minz_View::prependTitle (Minz_Translate::t ('logs') . ' - ');
 
 		if (Minz_Request::isPost ()) {
-			file_put_contents(LOG_PATH . '/application.log', '');
+			file_put_contents(LOG_PATH . '/' . Minz_Configuration::currentUser() . '.log', '');	//Truncate
 		}
 
-		$logs = FreshRSS_LogDAO::lines();	//TODO: ask only the necessary lines
+		$logs = FreshRSS_LogDAO::lines(Minz_Configuration::currentUser());	//TODO: ask only the necessary lines
 
 		//gestion pagination
 		$page = Minz_Request::param ('page', 1);

+ 2 - 4
app/Models/LogDAO.php

@@ -1,11 +1,9 @@
 <?php
 
 class FreshRSS_LogDAO {
-	private static $filename = '/application.log';
-
-	public static function lines() {
+	public static function lines($user) {
 		$logs = array ();
-		$handle = @fopen(LOG_PATH . self::$filename, 'r');
+		$handle = @fopen(LOG_PATH . '/' . $user . '.log', 'r');
 		if ($handle) {
 			while (($line = fgets($handle)) !== false) {
 				if (preg_match ('/^\[([^\[]+)\] \[([^\[]+)\] --- (.*)$/', $line, $matches)) {

+ 2 - 2
lib/Minz/Log.php

@@ -36,8 +36,8 @@ class Minz_Log {
 		if (! ($env === Minz_Configuration::SILENT
 		       || ($env === Minz_Configuration::PRODUCTION
 		       && ($level >= Minz_Log::NOTICE)))) {
-			if (is_null ($file_name)) {
-				$file_name = LOG_PATH . '/application.log';
+			if ($file_name === null) {
+				$file_name = LOG_PATH . '/' . Minz_Configuration::currentUser() . '.log';
 			}
 
 			switch ($level) {

+ 0 - 1
p/i/index.php

@@ -28,7 +28,6 @@ if (file_exists ('install.php')) {
 		require (LIB_PATH . '/http-conditional.php');
 		$dateLastModification = max(
 			@filemtime(DATA_PATH . '/touch.txt'),
-			@filemtime(LOG_PATH . '/application.log'),
 			@filemtime(DATA_PATH . '/config.php')
 		);
 		$_SERVER['QUERY_STRING'] .= '&utime=' . file_get_contents(DATA_PATH . '/touch.txt');	//For ETag