get_audit_logs_by_date
Retrieve audit logs within a specified date range for administrative monitoring and security analysis in the JSON Database Server.
Instructions
Belirli tarih aralığındaki audit logları getirir (Admin/Manager)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| token | Yes | JWT token | |
| startDate | Yes | Başlangıç tarihi (YYYY-MM-DD) | |
| endDate | Yes | Bitiş tarihi (YYYY-MM-DD) | |
| limit | No | Gösterilecek log sayısı (varsayılan: 100) |
Implementation Reference
- src/index.js:901-952 (handler)Handler for 'get_audit_logs_by_date' tool: validates token and permissions, checks date formats, calls getAuditLogsByDateRange helper, logs access, returns filtered logs.case 'get_audit_logs_by_date': { const { token, startDate, endDate, limit = 100 } = args; try { const user = checkPermissionWithToken(token, PERMISSIONS.AUDIT_READ); // Tarih format kontrolü const start = new Date(startDate); const end = new Date(endDate); if (isNaN(start.getTime()) || isNaN(end.getTime())) { return { content: [{ type: 'text', text: JSON.stringify({ success: false, message: 'Geçersiz tarih formatı. YYYY-MM-DD formatını kullanın' }) }] }; } const logs = await getAuditLogsByDateRange(startDate, endDate, limit); // Tarih bazlı audit log erişimini logla await auditLogger.dataAccessed(user.userId, user.role, 'audit_logs_by_date', { startDate, endDate, limit }); return { content: [{ type: 'text', text: JSON.stringify({ success: true, data: logs, dateRange: { startDate, endDate }, total: logs.length, requestedBy: { id: user.userId, role: user.role } }, null, 2) }] }; } catch (error) { return { content: [{ type: 'text', text: JSON.stringify({ success: false, message: error.message, requiredPermission: PERMISSIONS.AUDIT_READ }) }] }; } }
- src/index.js:343-355 (schema)Input schema definition and registration for the 'get_audit_logs_by_date' tool in the tools list.name: 'get_audit_logs_by_date', description: 'Belirli tarih aralığındaki audit logları getirir (Admin/Manager)', inputSchema: { type: 'object', properties: { token: { type: 'string', description: 'JWT token' }, startDate: { type: 'string', description: 'Başlangıç tarihi (YYYY-MM-DD)' }, endDate: { type: 'string', description: 'Bitiş tarihi (YYYY-MM-DD)' }, limit: { type: 'number', description: 'Gösterilecek log sayısı (varsayılan: 100)' } }, required: ['token', 'startDate', 'endDate'] } },
- src/audit.js:137-154 (helper)Helper function that filters and retrieves audit logs by date range from the audit log data file.export async function getAuditLogsByDateRange(startDate, endDate, limit = 100) { try { const auditData = await readAuditLogs(); const start = new Date(startDate); const end = new Date(endDate); return auditData.logs .filter(log => { const logDate = new Date(log.timestamp); return logDate >= start && logDate <= end; }) .slice(-limit) .reverse(); } catch (error) { console.error('Tarih aralığı audit log hatası:', error); return []; } }