|
| 1 | +# Changelog |
| 2 | + |
| 3 | +All notable changes to `initphp/logger` are documented here. |
| 4 | +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) |
| 5 | +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). |
| 6 | + |
| 7 | +## [Unreleased] |
| 8 | + |
| 9 | +### Added |
| 10 | + |
| 11 | +- Full PSR-3 v3 compliance: every handler now implements |
| 12 | + `Psr\Log\LoggerInterface` directly, including `Logger`, which previously |
| 13 | + relied on `__call()` for dispatch. |
| 14 | +- `Throwable` rendering for context placeholders — any `\Throwable` value in |
| 15 | + the context array is rendered as `Class(code): message in file:line`. |
| 16 | +- `string|\Stringable` accepted as message type across all handlers. |
| 17 | +- `FileLogger`: |
| 18 | + - Automatic creation of the parent directory (mode `0775`). |
| 19 | + - Concurrent-safe writes via `FILE_APPEND | LOCK_EX`. |
| 20 | + - `getPath()` accessor returning the token-interpolated path. |
| 21 | +- `PDOLogger`: |
| 22 | + - Table-name validation against `/^[A-Za-z_][A-Za-z0-9_]*$/` to prevent |
| 23 | + identifier injection. |
| 24 | + - Distinct, specific error messages for each invalid construction path. |
| 25 | + - `getTable()` accessor. |
| 26 | +- `Logger`: |
| 27 | + - At least one logger is now required at construction time. |
| 28 | + - Variadic `LoggerInterface` typing — non-`LoggerInterface` arguments raise |
| 29 | + `TypeError` instead of being silently dropped. |
| 30 | + - `getLoggers()` accessor. |
| 31 | +- Comprehensive PHPUnit test suite (45 tests, 80 assertions). |
| 32 | +- PHPStan (`level: max`) and PHP-CS-Fixer (PSR-12) configured and CI-enforced. |
| 33 | +- GitHub Actions CI matrix: PHP 8.0 / 8.1 / 8.2 / 8.3 / 8.4. |
| 34 | +- `docs/` directory with eight topic guides (getting started, file logger, |
| 35 | + PDO logger, multi-logger, custom handlers, PSR-3 context, recipes, testing). |
| 36 | + |
| 37 | +### Changed |
| 38 | + |
| 39 | +- **Minimum PHP version raised to 8.0** (was 5.6). PHP 8.0+ is required for |
| 40 | + PSR-3 v3 anyway. |
| 41 | +- **`psr/log` constraint bumped to `^3.0`** (was the pinned `1.1.4`). |
| 42 | +- All source files now declare `strict_types=1` and use property/parameter/ |
| 43 | + return-type declarations. |
| 44 | +- `Logger` is now `final`. Sub-classing it was never documented; users who |
| 45 | + need to customise fan-out behaviour should compose with `LoggerInterface`. |
| 46 | +- Log lines emitted by `FileLogger` now terminate with `PHP_EOL` instead of |
| 47 | + beginning with one — the previous behaviour produced a stray empty line at |
| 48 | + the top of every log file and made tailing awkward. |
| 49 | + |
| 50 | +### Fixed |
| 51 | + |
| 52 | +- `HelperTrait::$levels` no longer contains `LogLevel::WARNING` twice; the |
| 53 | + list now mirrors the canonical eight PSR-3 levels in severity order. |
| 54 | +- `FileLogger` no longer silently swallows write failures with the `@` |
| 55 | + operator; failures are reported through `error_log()`. |
| 56 | +- `FileLogger` rejects missing/empty/non-string `path` options at |
| 57 | + construction with a clear `InvalidArgumentException`, instead of failing |
| 58 | + obliquely at the first write. |
| 59 | +- `PDOLogger` raises specific, actionable `InvalidArgumentException` messages |
| 60 | + for each missing or wrongly-typed option (previously a single generic |
| 61 | + "It must be a PDO object." message was thrown for several distinct |
| 62 | + failures). |
| 63 | +- `PDOLogger` uses `Psr\Log\InvalidArgumentException` consistently per |
| 64 | + PSR-3 §1.1 (the previous code imported it but threw the SPL variant). |
| 65 | +- `PDOLogger::__destruct` removed — manually nulling an injected PDO is not |
| 66 | + the logger's responsibility and could mislead readers about ownership. |
| 67 | + |
| 68 | +### Removed |
| 69 | + |
| 70 | +- `Logger::__call()` magic dispatch. The class now implements |
| 71 | + `LoggerInterface` properly. |
| 72 | + |
| 73 | + **Behaviour change for callers:** Previously, calling an unknown method on |
| 74 | + `Logger` (e.g. `$logger->banana()`) silently no-op'd via `__call()`. |
| 75 | + Such calls now raise `Error: Call to undefined method |
| 76 | + InitPHP\Logger\Logger::banana()` at the PHP level. Legitimate PSR-3 calls |
| 77 | + (`emergency()` … `debug()`, `log()`) are unaffected. |
| 78 | + |
| 79 | +## 1.0 - 2022-03-11 |
| 80 | + |
| 81 | +Initial release. |
0 commit comments