mirror of
https://github.com/ceratic/MediaCollectorLibary.git
synced 2026-05-13 23:56:46 +02:00
...
This commit is contained in:
96
check_sync_logs.php
Normal file
96
check_sync_logs.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Sync Log Viewer
|
||||
*
|
||||
* This script helps you view recent sync logs and check the status of your sync operations.
|
||||
* Run this script to see what happened during the last sync operations.
|
||||
*/
|
||||
|
||||
// Check if we're in the right directory
|
||||
if (!file_exists('app/Services/BaseSyncService.php')) {
|
||||
echo "Error: Please run this script from the project root directory.\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once 'vendor/autoload.php';
|
||||
|
||||
// Simple database connection for viewing sync logs
|
||||
try {
|
||||
$pdo = new PDO('sqlite:database/database.sqlite');
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
echo "=== SYNC LOG VIEWER ===\n\n";
|
||||
|
||||
// Get recent sync logs
|
||||
$stmt = $pdo->prepare("
|
||||
SELECT sl.*, s.display_name as source_name
|
||||
FROM sync_logs sl
|
||||
JOIN sources s ON sl.source_id = s.id
|
||||
ORDER BY sl.created_at DESC
|
||||
LIMIT 10
|
||||
");
|
||||
$stmt->execute();
|
||||
$logs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if (empty($logs)) {
|
||||
echo "No sync logs found. Run a sync operation first.\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
echo "RECENT SYNC OPERATIONS:\n";
|
||||
echo str_repeat("-", 80) . "\n";
|
||||
|
||||
foreach ($logs as $log) {
|
||||
$status = strtoupper($log['status']);
|
||||
$statusColor = match($log['status']) {
|
||||
'completed' => '✅',
|
||||
'failed' => '❌',
|
||||
'running' => '🔄',
|
||||
default => '❓'
|
||||
};
|
||||
|
||||
echo "{$statusColor} {$log['source_name']} - {$status} - {$log['created_at']}\n";
|
||||
echo " Type: {$log['sync_type']} | Processed: {$log['processed_items']} | New: {$log['new_items']} | Updated: {$log['updated_items']}\n";
|
||||
|
||||
if ($log['message']) {
|
||||
echo " Message: {$log['message']}\n";
|
||||
}
|
||||
|
||||
if ($log['errors']) {
|
||||
$errors = json_decode($log['errors'], true);
|
||||
if (is_array($errors)) {
|
||||
echo " Errors: " . implode(', ', $errors) . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
echo "\n";
|
||||
}
|
||||
|
||||
// Check for log files
|
||||
$logFiles = glob('logs/*.log');
|
||||
if (!empty($logFiles)) {
|
||||
echo "\nLOG FILES AVAILABLE:\n";
|
||||
echo str_repeat("-", 80) . "\n";
|
||||
|
||||
// Sort by modification time, newest first
|
||||
usort($logFiles, function($a, $b) {
|
||||
return filemtime($b) - filemtime($a);
|
||||
});
|
||||
|
||||
foreach (array_slice($logFiles, 0, 5) as $logFile) {
|
||||
$size = filesize($logFile);
|
||||
$modified = date('Y-m-d H:i:s', filemtime($logFile));
|
||||
echo "📄 " . basename($logFile) . " ({$size} bytes) - {$modified}\n";
|
||||
}
|
||||
|
||||
echo "\nTo view a specific log file, run: tail -f logs/filename.log\n";
|
||||
} else {
|
||||
echo "\nNo log files found yet. Log files are created during sync operations.\n";
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo "Error: " . $e->getMessage() . "\n";
|
||||
echo "Make sure your database is set up correctly.\n";
|
||||
exit(1);
|
||||
}
|
||||
Reference in New Issue
Block a user