/** * @param ContainerInterface $dic */ public function wire(ContainerInterface $dic) { if (empty($dic['Yapeal.Log.Strategy'])) { $dic['Yapeal.Log.Strategy'] = function () use($dic) { return new $dic['Yapeal.Log.Handlers.strategy']((int) $dic['Yapeal.Log.threshold']); }; } if (empty($dic['Yapeal.Log.Logger'])) { $dic['Yapeal.Log.Logger'] = function () use($dic) { $group = []; $lineFormatter = new LineFormatter(null, 'U.u', true, true); $lineFormatter->includeStacktraces(); /** * @var \Monolog\Handler\HandlerInterface $handler */ if (PHP_SAPI === 'cli') { $handler = new $dic['Yapeal.Log.Handlers.stream']('php://stderr', 100); $handler->setFormatter($lineFormatter); $group[] = $handler; } $handler = new $dic['Yapeal.Log.Handlers.stream']($dic['Yapeal.Log.dir'] . $dic['Yapeal.Log.fileName'], 100); $group[] = $handler->setFormatter($lineFormatter); return new $dic['Yapeal.Log.Handlers.class']($dic['Yapeal.Log.channel'], [new $dic['Yapeal.Log.Handlers.fingersCrossed'](new $dic['Yapeal.Log.Handlers.group']($group), $dic['Yapeal.Log.Strategy'], (int) $dic['Yapeal.Log.bufferSize'], true, false)]); }; } /** * @var \Yapeal\Event\MediatorInterface $mediator */ $mediator = $dic['Yapeal.Event.Mediator']; $mediator->addServiceListener('Yapeal.Log.log', ['Yapeal.Log.Logger', 'logEvent'], 'last'); }
/** * @param ContainerInterface $dic */ public function wire(ContainerInterface $dic) { if (empty($dic['Yapeal.Error.Strategy'])) { $dic['Yapeal.Error.Strategy'] = function () use($dic) { return new $dic['Yapeal.Error.Handlers.strategy']((int) $dic['Yapeal.Error.threshold']); }; } if (empty($dic['Yapeal.Error.Logger'])) { $dic['Yapeal.Error.Logger'] = function () use($dic) { /** * @var Logger $logger */ $logger = new $dic['Yapeal.Error.Handlers.class']($dic['Yapeal.Error.channel']); $group = []; $lineFormatter = new LineFormatter(null, 'U.u', true, true); $lineFormatter->includeStacktraces(); /** * @var \Monolog\Handler\StreamHandler $handler */ if ('cli' === PHP_SAPI) { $handler = new $dic['Yapeal.Error.Handlers.stream']('php://stderr', 100); $group[] = $handler->setFormatter($lineFormatter); } $handler = new $dic['Yapeal.Error.Handlers.stream']($dic['Yapeal.Error.dir'] . $dic['Yapeal.Error.fileName'], 100); $group[] = $handler->setFormatter($lineFormatter); $logger->pushHandler(new $dic['Yapeal.Error.Handlers.fingersCrossed'](new $dic['Yapeal.Error.Handlers.group']($group), $dic['Yapeal.Error.Strategy'], (int) $dic['Yapeal.Error.bufferSize'], true, false)); /** * @var \Monolog\ErrorHandler $error */ $error = $dic['Yapeal.Error.Handlers.error']; $error::register($logger, [], (int) $dic['Yapeal.Error.threshold'], (int) $dic['Yapeal.Error.threshold']); return $error; }; // Activate error logger now since it is needed to log any future fatal // errors or exceptions. $dic['Yapeal.Error.Logger']; } }