Bicycle/App/Controller/Admin/LogsController.php
Egor Isaev 858e574e60 dev
2026-08-06 15:45:09 +03:00

45 lines
1.3 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* @package Bicycle
* @author Egor Isaev
* @description LogsController.php
* @copyright (c) 24/06/2026
*/
namespace App\Controller\Admin;
use System\Classes\FileLogReader;
use System\Classes\Request;
/**
* Просмотр и поиск логов. URL: /admin/logs
*/
class LogsController extends AdminController
{
/**
* Список записей лога с фильтрами (дата, канал, уровень, текст).
*
* @return string
* @throws \System\Classes\MyException
*/
public function indexAction(): string
{
$request = Request::$current;
// Позже FileLogReader заменяется на DbLogReader без изменения остального.
$reader = new FileLogReader();
$filters = [
'date' => $request?->query('date') ?: date('Y-m-d'),
'channel' => $request?->query('channel') ?: 'action',
'level' => $request?->query('level') ?: '',
'q' => $request?->query('q') ?: '',
];
return $this->render('logs', [
'entries' => $reader->read($filters),
'filters' => $filters,
'dates' => $reader->dates(),
]);
}
}