# php-fig/log architecture

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

- Interactive diagram: https://gitdiagram.com/php-fig/log
- Repository: https://github.com/php-fig/log

## Overview

PSR Log is a small PSR-3 contract library, not a logging backend. Applications call the logger contract with a severity, message, and context; implementations may use the abstract base and trait to map severity methods to generic logging, while NullLogger intentionally discards entries. Logger-aware interfaces and a trait provide optional logger injection. The source set contains no storage or external-service integration.

Main entry points: [`src/LoggerInterface.php`](https://github.com/php-fig/log/blob/master/src/LoggerInterface.php) (Logger interface), [`src/AbstractLogger.php`](https://github.com/php-fig/log/blob/master/src/AbstractLogger.php) (Abstract logger), [`src/LoggerTrait.php`](https://github.com/php-fig/log/blob/master/src/LoggerTrait.php) (Level delegation), [`src/NullLogger.php`](https://github.com/php-fig/log/blob/master/src/NullLogger.php) (No-op logger)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_contracts["Logging contracts"]
  node_logger_contract["Logger interface"]
  node_levels["Severity constants<br/>[LogLevel.php]"]
  node_invalid_argument["Invalid argument type"]
end

subgraph group_implementation["Logger conveniences"]
  node_abstract_logger["Abstract logger<br/>[AbstractLogger.php]"]
  node_logger_trait["Level delegation<br/>[LoggerTrait.php]"]
  node_null_logger["No-op logger<br/>[NullLogger.php]"]
end

subgraph group_injection["Logger injection"]
  node_aware_contract["Aware interface"]
  node_aware_trait["Logger setter"]
end

node_application(("Application code"))

node_application -->|"calls methods"| node_logger_contract
node_abstract_logger -->|"implements"| node_logger_contract
node_abstract_logger -->|"uses"| node_logger_trait
node_logger_trait -->|"uses severity"| node_levels
node_null_logger -->|"extends"| node_abstract_logger
node_aware_trait -->|"accepts logger"| node_logger_contract
node_aware_contract -->|"requires logger"| node_logger_contract

click node_logger_contract "https://github.com/php-fig/log/blob/master/src/LoggerInterface.php"
click node_levels "https://github.com/php-fig/log/blob/master/src/LogLevel.php"
click node_invalid_argument "https://github.com/php-fig/log/blob/master/src/InvalidArgumentException.php"
click node_abstract_logger "https://github.com/php-fig/log/blob/master/src/AbstractLogger.php"
click node_logger_trait "https://github.com/php-fig/log/blob/master/src/LoggerTrait.php"
click node_null_logger "https://github.com/php-fig/log/blob/master/src/NullLogger.php"
click node_aware_contract "https://github.com/php-fig/log/blob/master/src/LoggerAwareInterface.php"
click node_aware_trait "https://github.com/php-fig/log/blob/master/src/LoggerAwareTrait.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_logger_contract,node_levels,node_invalid_argument toneBlue
class node_abstract_logger,node_logger_trait,node_null_logger toneAmber
class node_aware_contract,node_aware_trait toneMint
class node_application toneIndigo
```

## Components

### Logging contracts

- [Logger interface](https://github.com/php-fig/log/blob/master/src/LoggerInterface.php): `src/LoggerInterface.php`
- [Severity constants](https://github.com/php-fig/log/blob/master/src/LogLevel.php): `src/LogLevel.php`
- [Invalid argument type](https://github.com/php-fig/log/blob/master/src/InvalidArgumentException.php): `src/InvalidArgumentException.php`

### Logger conveniences

- [Abstract logger](https://github.com/php-fig/log/blob/master/src/AbstractLogger.php): `src/AbstractLogger.php`
- [Level delegation](https://github.com/php-fig/log/blob/master/src/LoggerTrait.php): `src/LoggerTrait.php`
- [No-op logger](https://github.com/php-fig/log/blob/master/src/NullLogger.php): `src/NullLogger.php`

### Logger injection

- [Aware interface](https://github.com/php-fig/log/blob/master/src/LoggerAwareInterface.php): `src/LoggerAwareInterface.php`
- [Logger setter](https://github.com/php-fig/log/blob/master/src/LoggerAwareTrait.php): `src/LoggerAwareTrait.php`

### Other components

- **Application code**

## Connections

- Application code → Logger interface: calls methods (evidence: `README.md`)
- Abstract logger → Logger interface: implements (evidence: `src/AbstractLogger.php`)
- Abstract logger → Level delegation: uses (evidence: `src/AbstractLogger.php`)
- Level delegation → Severity constants: uses severity (evidence: `src/LoggerTrait.php`)
- No-op logger → Abstract logger: extends (evidence: `src/NullLogger.php`)
- Logger setter → Logger interface: accepts logger (evidence: `src/LoggerAwareTrait.php`)
- Aware interface → Logger interface: requires logger (evidence: `src/LoggerAwareInterface.php`)
