cinema-studio-pro/backend/get_logs.php
2026-01-13 14:52:37 +05:30

38 lines
856 B
PHP

<?php
session_start();
// Security check - only allow in development
if (!defined('GEMINI_API_KEY') || empty(GEMINI_API_KEY)) {
require_once 'config.php';
}
header('Content-Type: application/json');
// Get the last 50 lines from PHP error log
$errorLog = ini_get('error_log');
if (empty($errorLog)) {
$errorLog = '/tmp/php_errors.log'; // fallback
}
$logs = [];
if (file_exists($errorLog)) {
$lines = file($errorLog);
$recentLines = array_slice($lines, -50); // Last 50 lines
foreach ($recentLines as $line) {
$line = trim($line);
if (!empty($line)) {
$logs[] = $line;
}
}
} else {
$logs[] = "Error log not found at: $errorLog";
$logs[] = "Check your php.ini for error_log location";
}
echo json_encode([
'success' => true,
'logs' => $logs,
'log_file' => $errorLog
]);