mpdf/psr-log-aware-trait
Provides a PSR-3 LoggerAwareTrait implementation used by mPDF components. Adds simple logger injection and access following the psr/log LoggerAwareInterface, making it easy to add optional logging support without duplicating boilerplate across classes.
This package provides a simple trait (Mpdf\PsrLogAwareTrait) to make classes compatible with any PSR-3 logger implementation — regardless of whether your project uses psr/log v1, v2, or v3. Start by including it in any class that needs to accept and use a PSR-3 logger:
use Mpdf\PsrLogAwareTrait;
use Psr\Log\LoggerInterface;
class MyService
{
use PsrLogAwareTrait;
public function __construct(?LoggerInterface $logger = null)
{
$this->setLogger($logger);
}
public function doSomething()
{
$this->logger->info('Starting process…');
// ...
}
}
No further setup is required — the trait handles internal logger compatibility behind the scenes.
setLogger() early in the request lifecycle.null loggers — no extra if ($this->logger) checks needed.Psr\Log\LoggerInterface (or ?LoggerInterface for optional), not concrete implementations.Mpdf\…), it’s not tied to the mpdf/mpdf package — it’s generic and version-agnostic.mpdf/mpdf). Run composer show mPDF/psr-log-aware-trait to confirm.setLogger() — the trait doesn’t auto-inject.psr/log version doesn’t conflict with how other packages expect it (e.g., mpdf/mpdf historically lagged on PSR-3 v2+ support — this trait helps bridge that).psr/log version conflicts (e.g., ^1.0 || ^2.0 || ^3.0)How can I help you explore Laravel packages today?