src/Logger/functions.php
source
| 1 | <?php |
| 2 | |
| 3 | namespace mini; |
| 4 | |
| 5 | use mini\Mini; |
| 6 | use Psr\Log\LoggerInterface; |
| 7 | |
| 8 | /** |
| 9 | * Logger Feature - Global Helper Functions |
| 10 | * |
| 11 | * These functions provide the public API for the mini\Logger feature. |
| 12 | */ |
| 13 | |
| 14 | // Register Logger service |
| 15 | Mini::$mini->addService(LoggerInterface::class, Lifetime::Singleton, fn() => Mini::$mini->loadServiceConfig(LoggerInterface::class)); |
| 16 | |
| 17 | /** |
| 18 | * Get the application logger instance |
| 19 | * |
| 20 | * Returns a PSR-3 compatible logger. By default, uses the built-in Logger |
| 21 | * that writes to PHP's error_log with MessageFormatter interpolation. |
| 22 | * Can be overridden via _config/Psr/Log/LoggerInterface.php. |
| 23 | * |
| 24 | * @return LoggerInterface PSR-3 logger instance (singleton) |
| 25 | */ |
| 26 | function log(): LoggerInterface |
| 27 | { |
| 28 | return Mini::$mini->get(LoggerInterface::class); |
| 29 | } |
| 30 |