-
Notifications
You must be signed in to change notification settings - Fork 3
Add Journal entity support with PSR-3 compatibility #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
KarlsonComplete
wants to merge
6
commits into
mesilov:claude/implement-issue-72-01PyCT5q1ySkhYBu5ehAcnL9
Choose a base branch
from
KarlsonComplete:claude/implement-issue-72-01PyCT5q1ySkhYBu5ehAcnL9
base: claude/implement-issue-72-01PyCT5q1ySkhYBu5ehAcnL9
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
cf789f2
Remove unused repository methods `deleteByApplicationInstallationId` …
KarlsonComplete e04d8b3
Refactor: normalize parameter naming, add missing doc punctuation, an…
KarlsonComplete 91f2c32
add memberId
KarlsonComplete 9a8fa68
Refactor: rename `JournalContext` to `Context`, update related tests …
KarlsonComplete a574def
Refactor: move `Domain` value object to `Kernel` namespace, update re…
KarlsonComplete d4a44a8
Refactor: fix spacing issues, optimize imports, and improve code form…
KarlsonComplete File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 2 additions & 4 deletions
6
...urnal.ValueObjects.JournalContext.dcm.xml → ...urnal.Entity.ValueObjects.Context.dcm.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,11 @@ | ||
| <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" | ||
| xmlns:xs="https://www.w3.org/2001/XMLSchema" | ||
| xmlns:orm="https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> | ||
| <embeddable name="Bitrix24\Lib\Journal\ValueObjects\JournalContext"> | ||
| <field name="label" type="string" column="label" nullable="false"/> | ||
|
|
||
| <embeddable name="Bitrix24\Lib\Journal\Entity\ValueObjects\Context"> | ||
| <field name="payload" type="json" column="payload" nullable="true"/> | ||
|
|
||
| <field name="bitrix24UserId" type="integer" column="bitrix24_user_id" nullable="true"/> | ||
|
|
||
| <field name="ipAddress" type="darsyn_ip" column="ip_address" nullable="true"/> | ||
| <field name="ipAddress" type="ip_address" column="ip_address" nullable="true"/> | ||
| </embeddable> | ||
| </doctrine-mapping> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,30 +14,31 @@ | |
| namespace Bitrix24\Lib\Journal\Controller; | ||
|
|
||
| use Bitrix24\Lib\Journal\Entity\LogLevel; | ||
| use Bitrix24\Lib\Journal\ReadModel\JournalItemReadRepository; | ||
| use Bitrix24\Lib\Journal\Infrastructure\Doctrine\JournalItemReadRepository; | ||
| use Bitrix24\Lib\Kernel\ValueObjects\Domain; | ||
| use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
| use Symfony\Component\HttpFoundation\Request; | ||
| use Symfony\Component\HttpFoundation\Response; | ||
| use Symfony\Component\Uid\Uuid; | ||
|
|
||
| /** | ||
| * Admin controller for journal management | ||
| * Developer should configure routes in their application | ||
| * Developer should configure routes in their application. | ||
| */ | ||
| class JournalAdminController extends AbstractController | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Будет вынесен в другой реп, сейчас выпиливаем |
||
| { | ||
| public function __construct( | ||
| private readonly JournalItemReadRepository $journalReadRepository | ||
| ) { | ||
| } | ||
| ) {} | ||
|
|
||
| /** | ||
| * List journal items with filters and pagination | ||
| * List journal items with filters and pagination. | ||
| */ | ||
| public function list(Request $request): Response | ||
| { | ||
| $page = max(1, $request->query->getInt('page', 1)); | ||
| $domainUrl = $request->query->get('domain'); | ||
| $memberId = $request->query->get('member_id'); | ||
| $levelValue = $request->query->get('level'); | ||
| $label = $request->query->get('label'); | ||
|
|
||
|
|
@@ -47,8 +48,9 @@ public function list(Request $request): Response | |
| } | ||
|
|
||
| $pagination = $this->journalReadRepository->findWithFilters( | ||
| domainUrl: $domainUrl ?: null, | ||
| level: $level, | ||
| memberId: $memberId ?: null, | ||
| domain: $domainUrl ? new Domain($domainUrl) : null, | ||
| logLevel: $level, | ||
| label: $label ?: null, | ||
| page: $page, | ||
| limit: 50 | ||
|
|
@@ -61,6 +63,7 @@ public function list(Request $request): Response | |
| 'pagination' => $pagination, | ||
| 'currentFilters' => [ | ||
| 'domain' => $domainUrl, | ||
| 'member_id' => $memberId, | ||
| 'level' => $levelValue, | ||
| 'label' => $label, | ||
| ], | ||
|
|
@@ -71,7 +74,7 @@ public function list(Request $request): Response | |
| } | ||
|
|
||
| /** | ||
| * Show journal item details | ||
| * Show journal item details. | ||
| */ | ||
| public function show(string $id): Response | ||
| { | ||
|
|
@@ -83,7 +86,7 @@ public function show(string $id): Response | |
|
|
||
| $journalItem = $this->journalReadRepository->findById($uuid); | ||
|
|
||
| if (!$journalItem) { | ||
| if (null === $journalItem) { | ||
| throw $this->createNotFoundException('Journal item not found'); | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,7 +20,8 @@ $factory = $container->get(JournalLoggerFactory::class); | |
|
|
||
| // Создаем логгер для конкретной установки приложения | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Доку пересоздадим, когда будет итоговая архитектура журнала |
||
| $installationId = Uuid::fromString('...'); | ||
| $logger = $factory->createLogger($installationId); | ||
| $memberId = '...'; | ||
| $logger = $factory->createLogger($memberId, $installationId); | ||
|
|
||
| // Используем как обычный PSR-3 логгер | ||
| $logger->info('Синхронизация завершена', [ | ||
|
|
@@ -50,6 +51,7 @@ use Bitrix24\Lib\Journal\Services\JournalLogger; | |
| use Bitrix24\Lib\Journal\Infrastructure\Doctrine\DoctrineDbalJournalItemRepository; | ||
|
|
||
| $logger = new JournalLogger( | ||
| memberId: $memberId, | ||
| applicationInstallationId: $installationId, | ||
| repository: $repository, | ||
| entityManager: $entityManager | ||
|
|
@@ -74,13 +76,14 @@ $logger->debug('Отладочная информация'); | |
| use Bitrix24\Lib\Journal\Entity\JournalItem; | ||
|
|
||
| // Создание через статические методы | ||
| $item = JournalItem::info($installationId, 'Сообщение', [ | ||
| $item = JournalItem::info($memberId, $installationId, 'Сообщение', [ | ||
| 'label' => 'custom.label', | ||
| 'payload' => ['key' => 'value'] | ||
| ]); | ||
|
|
||
| // Или через create с явным указанием уровня | ||
| $item = JournalItem::create( | ||
| memberId: $memberId, | ||
| applicationInstallationId: $installationId, | ||
| level: LogLevel::error, | ||
| message: 'Сообщение об ошибке', | ||
|
|
@@ -103,10 +106,9 @@ $entityManager->flush(); | |
|
|
||
| // Поиск | ||
| $item = $repository->findById($uuid); | ||
| $items = $repository->findByApplicationInstallationId($installationId, LogLevel::error, 50, 0); | ||
| $items = $repository->findByApplicationInstallationId($memberId, $installationId, LogLevel::error, 50, 0); | ||
|
|
||
| // Очистка | ||
| $deleted = $repository->deleteByApplicationInstallationId($installationId); | ||
| $deleted = $repository->deleteOlderThan(new CarbonImmutable('-30 days')); | ||
| ``` | ||
|
|
||
|
|
@@ -126,14 +128,15 @@ $repository->clear(); | |
| ### 4. Admin UI (ReadModel) | ||
|
|
||
| ```php | ||
| use Bitrix24\Lib\Journal\ReadModel\JournalItemReadRepository; | ||
| use Bitrix24\Lib\Journal\Infrastructure\Doctrine\JournalItemReadRepository; | ||
|
|
||
| $readRepo = new JournalItemReadRepository($entityManager, $paginator); | ||
|
|
||
| // Получение с фильтрами и пагинацией | ||
| $pagination = $readRepo->findWithFilters( | ||
| domainUrl: 'example.bitrix24.ru', | ||
| level: LogLevel::error, | ||
| memberId: '66c9893d5f30e6.45265697', | ||
| domain: new Domain('example.bitrix24.ru'), | ||
| logLevel: LogLevel::error, | ||
| label: 'b24.api.error', | ||
| page: 1, | ||
| limit: 50 | ||
|
|
@@ -185,6 +188,7 @@ class MyTest extends TestCase | |
| $entityManager = $this->createMock(EntityManagerInterface::class); | ||
|
|
||
| $this->logger = new JournalLogger( | ||
| '66c9893d5f30e6.45265697', | ||
| Uuid::v7(), | ||
| $this->repository, | ||
| $entityManager | ||
|
|
@@ -215,13 +219,15 @@ class MyTest extends TestCase | |
|
|
||
| Таблица `journal_item` с полями: | ||
| - `id` (UUID) - PK | ||
| - `member_id` (string) - ID портала Bitrix24 | ||
| - `application_installation_id` (UUID) - FK к установке приложения | ||
| - `created_at_utc` (timestamp) - время создания | ||
| - `level` (string) - уровень логирования | ||
| - `message` (text) - сообщение | ||
| - `label`, `payload`, `bitrix24_user_id`, `ip_address` - поля контекста | ||
|
|
||
| Индексы: | ||
| - `application_installation_id` | ||
| - `member_id, application_installation_id, level, created_at_utc` (composite) | ||
| - `member_id` | ||
| - `created_at_utc` | ||
| - `level` | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
нейминг