* Write to stream
* @param resource $stream
*/
protected function streamWrite($stream, LogRecord $record): void
{
fwrite($stream, (string) $record->formatted);
}
private function customErrorHandler(int $code, string $msg): bool
{
$this->errorMessage = preg_replace('{^(fopen|mkdir)\(.*?\): }', '', $msg);
if ($this->useLocking) {
// ignoring errors here, there's not much we can do about them
flock($stream, LOCK_EX);
}
$this->streamWrite($stream, $record);
if ($this->useLocking) {
flock($stream, LOCK_UN);
}
}
if ($this->nextRotation <= $record->datetime) {
$this->mustRotate = true;
$this->close();
}
parent::write($record);
}
/**
* Rotates the files.
*/
$record = $this->processRecord($record);
}
$record->formatted = $this->getFormatter()->format($record);
$this->write($record);
return false === $this->bubble;
}
/**
}
// once the record is initialized, send it to all handlers as long as the bubbling chain is not interrupted
try {
$handled = true;
if (true === $handler->handle(clone $record)) {
break;
}
} catch (Throwable $e) {
$this->handleException($e, $record);
* @param string|Stringable $message The log message
* @param mixed[] $context The log context
*/
public function critical(string|\Stringable $message, array $context = []): void
{
$this->addRecord(Level::Critical, (string) $message, $context);
}
/**
* Adds a log record at the ALERT level.
*
{
if (null !== $this->logger) {
if (null !== $logLevel) {
$this->logger->log($logLevel, $message, ['exception' => $exception]);
} elseif (!$exception instanceof HttpExceptionInterface || $exception->getStatusCode() >= 500) {
$this->logger->critical($message, ['exception' => $exception]);
} else {
$this->logger->error($message, ['exception' => $exception]);
}
}
}
break;
}
$e = FlattenException::createFromThrowable($throwable);
$this->logException($throwable, sprintf('Uncaught PHP Exception %s: "%s" at %s line %s', $e->getClass(), $e->getMessage(), $e->getFile(), $e->getLine()), $logLevel);
}
public function onKernelException(ExceptionEvent $event)
{
if (null === $this->controller) {
$this->called = true;
$this->priority ??= $dispatcher->getListenerPriority($eventName, $this->listener);
$e = $this->stopwatch->start($this->name, 'event_listener');
($this->optimizedListener ?? $this->listener)($event, $eventName, $dispatcher);
if ($e->isStarted()) {
$e->stop();
}
foreach ($listeners as $listener) {
if ($stoppable && $event->isPropagationStopped()) {
break;
}
$listener($event, $eventName, $this);
}
}
/**
* Sorts the internal list of listeners for the given event by priority.
} else {
$listeners = $this->getListeners($eventName);
}
if ($listeners) {
$this->callListeners($listeners, $eventName, $event);
}
return $event;
}
try {
$this->beforeDispatch($eventName, $event);
try {
$e = $this->stopwatch->start($eventName, 'section');
try {
$this->dispatcher->dispatch($event, $eventName);
} finally {
if ($e->isStarted()) {
$e->stop();
}
}
* @throws \Exception
*/
private function handleThrowable(\Throwable $e, Request $request, int $type): Response
{
$event = new ExceptionEvent($this, $request, $type, $e);
$this->dispatcher->dispatch($event, KernelEvents::EXCEPTION);
// a listener might have replaced the exception
$e = $event->getThrowable();
if (!$event->hasResponse()) {
if ($pop = $request !== $this->requestStack->getMainRequest()) {
$this->requestStack->push($request);
}
try {
$response = $this->handleThrowable($exception, $request, self::MAIN_REQUEST);
} finally {
if ($pop) {
$this->requestStack->pop();
}
}
if ($hasRun) {
throw $e;
}
$hasRun = true;
$kernel->terminateWithException($e, $request);
};
}
} elseif ($event instanceof ConsoleEvent && $app = $event->getCommand()->getApplication()) {
$output = $event->getOutput();
if ($output instanceof ConsoleOutputInterface) {
$this->exceptionHandler = null;
}
try {
if (null !== $exceptionHandler) {
return $exceptionHandler($exception);
}
$handlerException = $handlerException ?: $exception;
} catch (\Throwable $handlerException) {
}
if ($exception === $handlerException && null === $this->exceptionHandler) {
ErrorException
|
---|
ErrorException: Notice: fwrite(): Write of 518 bytes failed with errno=28 No space left on device at /var/www/webexciter/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:165 at Monolog\Handler\StreamHandler->streamWrite() (/var/www/webexciter/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:152) at Monolog\Handler\StreamHandler->write() (/var/www/webexciter/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php:113) at Monolog\Handler\RotatingFileHandler->write() (/var/www/webexciter/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php:44) at Monolog\Handler\AbstractProcessingHandler->handle() (/var/www/webexciter/vendor/monolog/monolog/src/Monolog/Logger.php:390) at Monolog\Logger->addRecord() (/var/www/webexciter/vendor/monolog/monolog/src/Monolog/Logger.php:658) at Monolog\Logger->critical() (/var/www/webexciter/vendor/symfony/http-kernel/EventListener/ErrorListener.php:163) at Symfony\Component\HttpKernel\EventListener\ErrorListener->logException() (/var/www/webexciter/vendor/symfony/http-kernel/EventListener/ErrorListener.php:78) at Symfony\Component\HttpKernel\EventListener\ErrorListener->logKernelException() (/var/www/webexciter/vendor/symfony/event-dispatcher/Debug/WrappedListener.php:115) at Symfony\Component\EventDispatcher\Debug\WrappedListener->__invoke() (/var/www/webexciter/vendor/symfony/event-dispatcher/EventDispatcher.php:230) at Symfony\Component\EventDispatcher\EventDispatcher->callListeners() (/var/www/webexciter/vendor/symfony/event-dispatcher/EventDispatcher.php:59) at Symfony\Component\EventDispatcher\EventDispatcher->dispatch() (/var/www/webexciter/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:153) at Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher->dispatch() (/var/www/webexciter/vendor/symfony/http-kernel/HttpKernel.php:223) at Symfony\Component\HttpKernel\HttpKernel->handleThrowable() (/var/www/webexciter/vendor/symfony/http-kernel/HttpKernel.php:114) at Symfony\Component\HttpKernel\HttpKernel->terminateWithException() (/var/www/webexciter/vendor/symfony/http-kernel/EventListener/DebugHandlersListener.php:125) at Symfony\Component\HttpKernel\EventListener\DebugHandlersListener::Symfony\Component\HttpKernel\EventListener\{closure}() (/var/www/webexciter/vendor/symfony/error-handler/ErrorHandler.php:540) at Symfony\Component\ErrorHandler\ErrorHandler->handleException() |