# ayaou/command-logger-bundle architecture

> Architecture diagram of the GitHub repository ayaou/command-logger-bundle, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ayaou/command-logger-bundle
- Repository: https://github.com/ayaou/command-logger-bundle

## Overview

Command Logger Bundle observes selected Symfony console command executions and records their arguments, timing, outcomes, errors, and optionally bounded output. The main flow runs from command lifecycle events through selection, tracking, redaction/capture, and persistence. Operators can query logs and statistics through console commands or a JSON-LD API; configuration also supports a separate Doctrine entity manager. Core listener and storage links are grounded in the source index and excerpts. Some command and listener implementations were not excerpted, so their documented capabilities are shown without speculative internal links.

Main entry points: [`src/EventListener/CommandLogger/CommandStartListener.php`](https://github.com/ayaou/command-logger-bundle/blob/main/src/EventListener/CommandLogger/CommandStartListener.php) (Start listener), [`src/Util/CommandLogWriter.php`](https://github.com/ayaou/command-logger-bundle/blob/main/src/Util/CommandLogWriter.php) (Log writer), [`src/EventListener/CommandLogger/CommandTerminateListener.php`](https://github.com/ayaou/command-logger-bundle/blob/main/src/EventListener/CommandLogger/CommandTerminateListener.php) (Terminate listener), [`src/Controller/Api/CommandLogController.php`](https://github.com/ayaou/command-logger-bundle/blob/main/src/Controller/Api/CommandLogController.php) (Log API controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_lifecycle["Command lifecycle"]
  node_start["Start listener"]
  node_error["Error listener"]
  node_terminate["Terminate listener"]
  node_selection["Command selection"]
  node_tracker["Execution tracker"]
end

subgraph group_recording["Log recording"]
  node_redactor["Parameter redaction"]
  node_capture["Output capture<br/>[OutputCapture.php]"]
  node_buffer["Bounded output buffer<br/>[OutputBuffer.php]"]
  node_capturefilter["Stream filter"]
  node_writer["Log writer"]
  node_entity["Command log entity<br/>[CommandLog.php]"]
  node_database[("Doctrine database")]
end

subgraph group_access["Log access"]
  node_filter["Query filters"]
  node_repository["Log repository"]
  node_statistics["Statistics"]
  node_show["Show log command"]
  node_statscmd["Statistics command"]
  node_purge["Purge command"]
  node_api["Log API controller"]
  node_jsonld["JSON-LD responses<br/>[JsonLdFactory.php]"]
end

subgraph group_setup["Bundle configuration"]
  node_attribute["Logger attribute<br/>[CommandLogger.php]"]
  node_compiler["Command compiler pass"]
  node_extension["Bundle extension"]
  node_config["Logger configuration<br/>[Configuration.php]"]
  node_bundle["Bundle registration"]
end

node_console(("Symfony command"))
node_client(("API client"))

node_console -->|"starts event"| node_start
node_console -->|"error event"| node_error
node_console -->|"terminates event"| node_terminate
node_start -->|"checks support"| node_selection
node_error -->|"checks support"| node_selection
node_terminate -->|"checks support"| node_selection
node_start -->|"records execution"| node_tracker
node_error -->|"retrieves execution"| node_tracker
node_terminate -->|"retrieves timing"| node_tracker
node_start -->|"redacts arguments"| node_redactor
node_start -->|"starts capture"| node_capture
node_terminate -->|"stops capture"| node_capture
node_capture -->|"appends output"| node_buffer
node_capture -->|"attaches filter"| node_capturefilter
node_start -->|"creates log"| node_writer
node_error -->|"records failure"| node_writer
node_terminate -->|"records outcome"| node_writer
node_writer -->|"maps fields"| node_entity
node_writer -->|"writes rows"| node_database
node_entity -->|"stored as"| node_database
node_show -->|"accepts filters"| node_filter
node_show -->|"queries logs"| node_repository
node_statscmd -->|"accepts filters"| node_filter
node_statscmd -->|"requests metrics"| node_statistics
node_purge -->|"deletes old logs"| node_repository
node_api -->|"accepts filters"| node_filter
node_api -->|"queries logs"| node_repository
node_api -->|"requests metrics"| node_statistics
node_api -->|"builds responses"| node_jsonld
node_client -.->|"requests logs"| node_api
node_attribute -->|"detected at build"| node_compiler
node_bundle -->|"registers pass"| node_compiler
node_extension -->|"loads configuration"| node_config
node_config -.->|"configures manager"| node_writer
node_config -.->|"configures capture"| node_capture

click node_start "https://github.com/ayaou/command-logger-bundle/blob/main/src/EventListener/CommandLogger/CommandStartListener.php"
click node_error "https://github.com/ayaou/command-logger-bundle/blob/main/src/EventListener/CommandLogger/CommandErrorListener.php"
click node_terminate "https://github.com/ayaou/command-logger-bundle/blob/main/src/EventListener/CommandLogger/CommandTerminateListener.php"
click node_selection "https://github.com/ayaou/command-logger-bundle/blob/main/src/Util/SupportedCommandResolver.php"
click node_tracker "https://github.com/ayaou/command-logger-bundle/blob/main/src/Util/CommandExecutionTracker.php"
click node_redactor "https://github.com/ayaou/command-logger-bundle/blob/main/src/Util/SensitiveParameterRedactor.php"
click node_capture "https://github.com/ayaou/command-logger-bundle/blob/main/src/Util/OutputCapture.php"
click node_buffer "https://github.com/ayaou/command-logger-bundle/blob/main/src/Util/OutputBuffer.php"
click node_capturefilter "https://github.com/ayaou/command-logger-bundle/blob/main/src/Util/OutputCaptureFilter.php"
click node_writer "https://github.com/ayaou/command-logger-bundle/blob/main/src/Util/CommandLogWriter.php"
click node_entity "https://github.com/ayaou/command-logger-bundle/blob/main/src/Entity/CommandLog.php"
click node_filter "https://github.com/ayaou/command-logger-bundle/blob/main/src/Dto/CommandLogFilter.php"
click node_repository "https://github.com/ayaou/command-logger-bundle/blob/main/src/Repository/CommandLogRepository.php"
click node_statistics "https://github.com/ayaou/command-logger-bundle/blob/main/src/Repository/CommandLogStatistics.php"
click node_show "https://github.com/ayaou/command-logger-bundle/blob/main/src/Command/ShowCommandLoggerEntriesCommand.php"
click node_statscmd "https://github.com/ayaou/command-logger-bundle/blob/main/src/Command/CommandLoggerStatisticsCommand.php"
click node_purge "https://github.com/ayaou/command-logger-bundle/blob/main/src/Command/PurgeCommandLoggerTableCommand.php"
click node_api "https://github.com/ayaou/command-logger-bundle/blob/main/src/Controller/Api/CommandLogController.php"
click node_jsonld "https://github.com/ayaou/command-logger-bundle/blob/main/src/Service/JsonLdFactory.php"
click node_attribute "https://github.com/ayaou/command-logger-bundle/blob/main/src/Attribute/CommandLogger.php"
click node_compiler "https://github.com/ayaou/command-logger-bundle/blob/main/src/DependencyInjection/Compiler/CommandLoggerPass.php"
click node_extension "https://github.com/ayaou/command-logger-bundle/blob/main/src/DependencyInjection/CommandLoggerExtension.php"
click node_config "https://github.com/ayaou/command-logger-bundle/blob/main/src/DependencyInjection/Configuration.php"
click node_bundle "https://github.com/ayaou/command-logger-bundle/blob/main/src/CommandLoggerBundle.php"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_start,node_error,node_terminate,node_selection,node_tracker,node_client toneBlue
class node_redactor,node_capture,node_buffer,node_capturefilter,node_writer,node_entity,node_database toneAmber
class node_filter,node_repository,node_statistics,node_show,node_statscmd,node_purge,node_api,node_jsonld toneMint
class node_attribute,node_compiler,node_extension,node_config,node_bundle toneRose
class node_console toneIndigo
```

## Components

### Command lifecycle

- [Start listener](https://github.com/ayaou/command-logger-bundle/blob/main/src/EventListener/CommandLogger/CommandStartListener.php): `src/EventListener/CommandLogger/CommandStartListener.php`
- [Error listener](https://github.com/ayaou/command-logger-bundle/blob/main/src/EventListener/CommandLogger/CommandErrorListener.php): `src/EventListener/CommandLogger/CommandErrorListener.php`
- [Terminate listener](https://github.com/ayaou/command-logger-bundle/blob/main/src/EventListener/CommandLogger/CommandTerminateListener.php): `src/EventListener/CommandLogger/CommandTerminateListener.php`
- [Command selection](https://github.com/ayaou/command-logger-bundle/blob/main/src/Util/SupportedCommandResolver.php): `src/Util/SupportedCommandResolver.php`
- [Execution tracker](https://github.com/ayaou/command-logger-bundle/blob/main/src/Util/CommandExecutionTracker.php): `src/Util/CommandExecutionTracker.php`

### Log recording

- [Parameter redaction](https://github.com/ayaou/command-logger-bundle/blob/main/src/Util/SensitiveParameterRedactor.php): `src/Util/SensitiveParameterRedactor.php`
- [Output capture](https://github.com/ayaou/command-logger-bundle/blob/main/src/Util/OutputCapture.php): `src/Util/OutputCapture.php`
- [Bounded output buffer](https://github.com/ayaou/command-logger-bundle/blob/main/src/Util/OutputBuffer.php): `src/Util/OutputBuffer.php`
- [Stream filter](https://github.com/ayaou/command-logger-bundle/blob/main/src/Util/OutputCaptureFilter.php): `src/Util/OutputCaptureFilter.php`
- [Log writer](https://github.com/ayaou/command-logger-bundle/blob/main/src/Util/CommandLogWriter.php): `src/Util/CommandLogWriter.php`
- [Command log entity](https://github.com/ayaou/command-logger-bundle/blob/main/src/Entity/CommandLog.php): `src/Entity/CommandLog.php`
- **Doctrine database**

### Log access

- [Query filters](https://github.com/ayaou/command-logger-bundle/blob/main/src/Dto/CommandLogFilter.php): `src/Dto/CommandLogFilter.php`
- [Log repository](https://github.com/ayaou/command-logger-bundle/blob/main/src/Repository/CommandLogRepository.php): `src/Repository/CommandLogRepository.php`
- [Statistics](https://github.com/ayaou/command-logger-bundle/blob/main/src/Repository/CommandLogStatistics.php): `src/Repository/CommandLogStatistics.php`
- [Show log command](https://github.com/ayaou/command-logger-bundle/blob/main/src/Command/ShowCommandLoggerEntriesCommand.php): `src/Command/ShowCommandLoggerEntriesCommand.php`
- [Statistics command](https://github.com/ayaou/command-logger-bundle/blob/main/src/Command/CommandLoggerStatisticsCommand.php): `src/Command/CommandLoggerStatisticsCommand.php`
- [Purge command](https://github.com/ayaou/command-logger-bundle/blob/main/src/Command/PurgeCommandLoggerTableCommand.php): `src/Command/PurgeCommandLoggerTableCommand.php`
- [Log API controller](https://github.com/ayaou/command-logger-bundle/blob/main/src/Controller/Api/CommandLogController.php): `src/Controller/Api/CommandLogController.php`
- [JSON-LD responses](https://github.com/ayaou/command-logger-bundle/blob/main/src/Service/JsonLdFactory.php): `src/Service/JsonLdFactory.php`

### Bundle configuration

- [Logger attribute](https://github.com/ayaou/command-logger-bundle/blob/main/src/Attribute/CommandLogger.php): `src/Attribute/CommandLogger.php`
- [Command compiler pass](https://github.com/ayaou/command-logger-bundle/blob/main/src/DependencyInjection/Compiler/CommandLoggerPass.php): `src/DependencyInjection/Compiler/CommandLoggerPass.php`
- [Bundle extension](https://github.com/ayaou/command-logger-bundle/blob/main/src/DependencyInjection/CommandLoggerExtension.php): `src/DependencyInjection/CommandLoggerExtension.php`
- [Logger configuration](https://github.com/ayaou/command-logger-bundle/blob/main/src/DependencyInjection/Configuration.php): `src/DependencyInjection/Configuration.php`
- [Bundle registration](https://github.com/ayaou/command-logger-bundle/blob/main/src/CommandLoggerBundle.php): `src/CommandLoggerBundle.php`

### Other components

- **Symfony command**
- **API client**

## Connections

- Symfony command → Start listener: starts event (evidence: `README.md`)
- Symfony command → Error listener: error event (evidence: `README.md`)
- Symfony command → Terminate listener: terminates event (evidence: `README.md`)
- Start listener → Command selection: checks support (evidence: `src/EventListener/CommandLogger/CommandStartListener.php`)
- Error listener → Command selection: checks support (evidence: `src/EventListener/CommandLogger/CommandErrorListener.php`)
- Terminate listener → Command selection: checks support (evidence: `src/EventListener/CommandLogger/CommandTerminateListener.php`)
- Start listener → Execution tracker: records execution (evidence: `src/EventListener/CommandLogger/CommandStartListener.php`)
- Error listener → Execution tracker: retrieves execution (evidence: `src/EventListener/CommandLogger/CommandErrorListener.php`)
- Terminate listener → Execution tracker: retrieves timing (evidence: `src/EventListener/CommandLogger/CommandTerminateListener.php`)
- Start listener → Parameter redaction: redacts arguments (evidence: `src/EventListener/CommandLogger/CommandStartListener.php`)
- Start listener → Output capture: starts capture (evidence: `src/EventListener/CommandLogger/CommandStartListener.php`)
- Terminate listener → Output capture: stops capture (evidence: `src/EventListener/CommandLogger/CommandTerminateListener.php`)
- Output capture → Bounded output buffer: appends output (evidence: `src/Util/OutputCapture.php`)
- Output capture → Stream filter: attaches filter (evidence: `src/Util/OutputCapture.php`)
- Start listener → Log writer: creates log (evidence: `src/EventListener/CommandLogger/CommandStartListener.php`)
- Error listener → Log writer: records failure (evidence: `src/EventListener/CommandLogger/CommandErrorListener.php`)
- Terminate listener → Log writer: records outcome (evidence: `src/EventListener/CommandLogger/CommandTerminateListener.php`)
- Log writer → Command log entity: maps fields (evidence: `src/Util/CommandLogWriter.php`)
- Log writer → Doctrine database: writes rows (evidence: `src/Util/CommandLogWriter.php`)
- Command log entity → Doctrine database: stored as (evidence: `src/Entity/CommandLog.php`)
- Show log command → Query filters: accepts filters (evidence: `src/Command/ShowCommandLoggerEntriesCommand.php`)
- Show log command → Log repository: queries logs (evidence: `src/Command/ShowCommandLoggerEntriesCommand.php`)
- Statistics command → Query filters: accepts filters (evidence: `src/Command/CommandLoggerStatisticsCommand.php`)
- Statistics command → Statistics: requests metrics (evidence: `src/Command/CommandLoggerStatisticsCommand.php`)
- Purge command → Log repository: deletes old logs (evidence: `src/Command/PurgeCommandLoggerTableCommand.php`)
- Log API controller → Query filters: accepts filters (evidence: `src/Controller/Api/CommandLogController.php`)
- Log API controller → Log repository: queries logs (evidence: `src/Controller/Api/CommandLogController.php`)
- Log API controller → Statistics: requests metrics (evidence: `src/Controller/Api/CommandLogController.php`)
- Log API controller → JSON-LD responses: builds responses (evidence: `src/Controller/Api/CommandLogController.php`)
- API client → Log API controller: requests logs (evidence: `README.md`)
- Logger attribute → Command compiler pass: detected at build (evidence: `src/DependencyInjection/Compiler/CommandLoggerPass.php`)
- Bundle registration → Command compiler pass: registers pass (evidence: `src/CommandLoggerBundle.php`)
- Bundle extension → Logger configuration: loads configuration (evidence: `src/DependencyInjection/CommandLoggerExtension.php`)
- Logger configuration → Log writer: configures manager (evidence: `README.md`)
- Logger configuration → Output capture: configures capture (evidence: `README.md`)
