fix time log when shared does not exists

This commit is contained in:
Fernando Ontiveros
2025-05-22 11:38:11 -04:00
parent e25afd88a4
commit ecce4ac6d6

View File

@@ -786,9 +786,27 @@ class Bootstrap
$endTime = microtime(true);
$time = $endTime - self::$startingTime;
Bootstrap::verifyPath(PATH_DATA . 'logs', true);
$fpt = fopen(PATH_DATA . 'logs/time.log', 'a');
fwrite($fpt, sprintf("%s %7.6f %-15s %s\n", date('Y-m-d H:i:s'), $time, getenv('REMOTE_ADDR'), $_SERVER ['REQUEST_URI']));
fclose($fpt);
// Define the log file path
$logFilePath = PATH_DATA . 'logs/time.log';
// Check if the directory exists, if not, create it
if (is_dir(PATH_DATA . 'logs')) {
// Attempt to open the log file
$fpt = fopen($logFilePath, 'a');
if ($fpt === false) {
// Handle the error if the file cannot be opened
error_log("Failed to open log file: " . $logFilePath);
return; // Exit or handle as needed
}
// Write to the log file
fwrite($fpt, sprintf("%s %7.6f %-15s %s\n", date('Y-m-d H:i:s'), $time, getenv('REMOTE_ADDR'), $_SERVER['REQUEST_URI']));
// Close the file
fclose($fpt);
}
}
/**