feat(logging): implement log pruning functionality
- Add LogPruneService to handle the deletion of old logs based on retention settings. - Create PruneLogsCommand to provide a console command for log pruning. - Introduce PruneLogsMessage and PruneLogsHandler for message handling related to log pruning. - Update the AST cache with new classes and their relationships.
This commit is contained in:
@@ -845,6 +845,7 @@ Returns all site configuration values.
|
||||
"support_phone": "",
|
||||
"max_cancel_hours_before": "24",
|
||||
"appointment_reminder_hours": "2",
|
||||
"log_retention_days": "90",
|
||||
"payment_test_mode": "0",
|
||||
"mellat_terminal_id": "",
|
||||
"mellat_username": "",
|
||||
@@ -984,6 +985,7 @@ Reject a pending request. **Permission:** `ROLE_ADMIN`
|
||||
| `tax_percent` | `10` | درصد مالیات |
|
||||
| `sms_panel_fee_rials` | `1500000` | هزینه ثابت پنل پیامک به ریال (از نوبت و اشتراک کسر میشود) |
|
||||
| `appointment_fee_rials` | `150000` | مبلغ هر نوبت به ریال؛ مبلغی که بیمار هنگام رزرو آنلاین پرداخت میکند. backend از همین کلید میخواند و در `GET /api/v1/payment/config` expose میشود |
|
||||
| `log_retention_days` | `90` | مدت نگهداری لاگها (روز)؛ کاماند روزانه `app:prune-logs` لاگهای قدیمیتر را حذف میکند. `0` = نگهداری نامحدود |
|
||||
|
||||
**ترتیب محاسبه** (در `CommissionService`): ۱) کسر `sms_panel_fee_rials` ۲) مالیاتِ استخراجی `afterSms × tax/(100+tax)` ۳) پورسانت = `netAfterTax × percent/100`. سهم نماینده به کیفپولش (`WalletTransaction` credit) واریز و یک ردیف `FinancialBreakdown` ثبت میشود (idempotent بر اساس `payment_id`).
|
||||
|
||||
@@ -1128,3 +1130,24 @@ Ordered by newest first (`id DESC`).
|
||||
Notes:
|
||||
- `context` is a JSON string (or `null`); a `Throwable` in the context is stored as a compact `Class: message @ file:line` string, never the raw object.
|
||||
- `created_at` is a Unix timestamp (integer).
|
||||
|
||||
### DELETE `/api/v1/admin/logs`
|
||||
|
||||
Delete **all** persisted logs (truncate the `app_log` table). Irreversible.
|
||||
|
||||
**Permission:** `ROLE_ADMIN`
|
||||
|
||||
#### Response `200`
|
||||
```json
|
||||
{ "success": true, "data": { "deleted": 137 } }
|
||||
```
|
||||
|
||||
- `deleted` — number of rows removed.
|
||||
|
||||
### Log Retention
|
||||
|
||||
Logs are pruned automatically based on the `log_retention_days` setting (see [Site Settings](#) — `GET`/`PATCH /api/v1/admin/settings`, whitelisted key `log_retention_days`, default `90`, `0` = keep forever).
|
||||
|
||||
- A daily scheduled task (`App\Shared\Logging\Message\PruneLogsMessage`, registered in `src/Schedule.php`, routed to `scheduler_default`) deletes logs older than `log_retention_days`.
|
||||
- Manual prune: `php bin/console app:prune-logs` (reads the same setting, deletes older-than-retention rows, prints the count).
|
||||
- Requires the scheduler worker: `php bin/console messenger:consume scheduler_default`.
|
||||
|
||||
Reference in New Issue
Block a user