I have declared the logger via DI
$di->set( 'logger', function () use ($config) {
$fileNameMain = strtr($config->logger->fileNames->cli->main, ['[%date%]' => date('Y-m-d')]); $fileNameEaisto = strtr($config->logger->fileNames->cli->eaisto, ['[%date%]' => date('Y-m-d')]); $adapterMain = new Stream($fileNameMain); $adapterEaisto = new Stream($fileNameEaisto); $logger = new Logger( 'messages', [ 'main' => $adapterMain, 'eaisto' => $adapterEaisto ] ); return $logger; }
);
and there is a class for handling exceptions:
namespace App\Services\Exceptions;
class EaistoException extends \Exception { public function __construct($msg){ $this->logger->critical($msg); } }
How do I pass the exception object to the logger? The above code causes an error:
Undefined property: App\Services\Exceptions\EaistoException::$logger
sorry for the stupid question :)