* {@inheritdoc}
*/
protected function write(array $record)
{
if (!is_resource($this->stream)) {
if (null === $this->url || '' === $this->url) {
throw new \LogicException('Missing stream url, the stream can not be opened. This may be caused by a premature call to close().');
}
$this->createDir();
$this->errorMessage = null;
set_error_handler(array($this, 'customErrorHandler'));
$this->stream = fopen($this->url, 'a');
if ($this->filePermission !== null) {
@chmod($this->url, $this->filePermission);
}
restore_error_handler();
if (!is_resource($this->stream)) {
$this->stream = null;
throw new \UnexpectedValueException(sprintf('The stream or file "%s" could not be opened in append mode: '.$this->errorMessage, $this->url));
}
$this->streamSetChunkSize();
}
if ($this->useLocking) {
// ignoring errors here, there's not much we can do about them
flock($this->stream, LOCK_EX);
}
$this->streamWrite($this->stream, $record);
if ($this->useLocking) {
flock($this->stream, LOCK_UN);
}
}
/**
* Write to stream
* @param resource $stream
* @param array $record
Arguments
"The stream or file "/var/www/mp2go/storage/logs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied"
*
* @author Jordi Boggiano <j.boggiano@seld.be>
* @author Christophe Coevoet <stof@notk.org>
*/
abstract class AbstractProcessingHandler extends AbstractHandler
{
/**
* {@inheritdoc}
*/
public function handle(array $record)
{
if (!$this->isHandling($record)) {
return false;
}
$record = $this->processRecord($record);
$record['formatted'] = $this->getFormatter()->format($record);
$this->write($record);
return false === $this->bubble;
}
/**
* Writes the record down to the log of the implementing handler
*
* @param array $record
* @return void
*/
abstract protected function write(array $record);
/**
* Processes a record.
*
* @param array $record
* @return array
*/
protected function processRecord(array $record)
{
Arguments
array:8 [
"message" => "file_put_contents(/var/www/mp2go/storage/framework/sessions/vfN1Bl8n8b4eUpQRCQuAcymROtTHUpeu5mvU7heH): failed to open stream: Permission denied"
"context" => array:1 [
"exception" => ErrorException {#35
#message: "file_put_contents(/var/www/mp2go/storage/framework/sessions/vfN1Bl8n8b4eUpQRCQuAcymROtTHUpeu5mvU7heH): failed to open stream: Permission denied"
#code: 0
#file: "/var/www/mp2go/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php"
#line: 122
#severity: E_WARNING
}
]
"level" => 400
"level_name" => "ERROR"
"channel" => "production"
"datetime" => DateTime @1749641380 {#637
date: 2025-06-11 08:29:40.719293 America/Sao_Paulo (-03:00)
}
"extra" => []
"formatted" => """
[2025-06-11 08:29:40] production.ERROR: file_put_contents(/var/www/mp2go/storage/framework/sessions/vfN1Bl8n8b4eUpQRCQuAcymROtTHUpeu5mvU7heH): failed to open stream: Permission denied {"exception":"[object] (ErrorException(code: 0): file_put_contents(/var/www/mp2go/storage/framework/sessions/vfN1Bl8n8b4eUpQRCQuAcymROtTHUpeu5mvU7heH): failed to open stream: Permission denied at /var/www/mp2go/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:122)\n
[stacktrace]\n
#0 [internal function]: Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(2, 'file_put_conten...', '/var/www/mp2go/...', 122, Array)\n
#1 /var/www/mp2go/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php(122): file_put_contents('/var/www/mp2go/...', 'a:4:{s:6:\"_toke...', 2)\n
#2 /var/www/mp2go/vendor/laravel/framework/src/Illuminate/Session/FileSessionHandler.php(83): Illuminate\\Filesystem\\Filesystem->put('/var/www/mp2go/...', 'a:4:{s:6:\"_toke...', true)\n
#3 /var/www/mp2go/vendor/laravel/framework/src/Illuminate/Session/Store.php(129): Illuminate\\Session\\FileSessionHandler->write('vfN1Bl8n8b4eUpQ...', 'a:4:{s:6:\"_toke...')\n
#4 /var/www/mp2go/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(87): Illuminate\\Session\\Store->save()\n
#5 /var/www/mp2go/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(218): Illuminate\\Session\\Middleware\\StartSession->terminate(Object(Illuminate\\Http\\Request), Object(Illuminate\\Http\\Response))\n
#6 /var/www/mp2go/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(189): Illuminate\\Foundation\\Http\\Kernel->terminateMiddleware(Object(Illuminate\\Http\\Request), Object(Illuminate\\Http\\Response))\n
#7 /var/www/mp2go/public/index.php(79): Illuminate\\Foundation\\Http\\Kernel->terminate(Object(Illuminate\\Http\\Request), Object(Illuminate\\Http\\Response))\n
#8 {main}\n
"} \n
"""
]
}
$ts->setTimezone(static::$timezone);
$record = array(
'message' => (string) $message,
'context' => $context,
'level' => $level,
'level_name' => $levelName,
'channel' => $this->name,
'datetime' => $ts,
'extra' => array(),
);
try {
foreach ($this->processors as $processor) {
$record = call_user_func($processor, $record);
}
while ($handler = current($this->handlers)) {
if (true === $handler->handle($record)) {
break;
}
next($this->handlers);
}
} catch (Exception $e) {
$this->handleException($e, $record);
}
return true;
}
/**
* Ends a log cycle and frees all resources used by handlers.
*
* Closing a Handler means flushing all buffers and freeing any open resources/handles.
* Handlers that have been closed should be able to accept log records again and re-open
* themselves on demand, but this may not always be possible depending on implementation.
*
* This is useful at the end of a request and will be called automatically on every handler
Arguments
array:8 [
"message" => "file_put_contents(/var/www/mp2go/storage/framework/sessions/vfN1Bl8n8b4eUpQRCQuAcymROtTHUpeu5mvU7heH): failed to open stream: Permission denied"
"context" => array:1 [
"exception" => ErrorException {#35
#message: "file_put_contents(/var/www/mp2go/storage/framework/sessions/vfN1Bl8n8b4eUpQRCQuAcymROtTHUpeu5mvU7heH): failed to open stream: Permission denied"
#code: 0
#file: "/var/www/mp2go/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php"
#line: 122
#severity: E_WARNING
}
]
"level" => 400
"level_name" => "ERROR"
"channel" => "production"
"datetime" => DateTime @1749641380 {#637
date: 2025-06-11 08:29:40.719293 America/Sao_Paulo (-03:00)
}
"extra" => []
"formatted" => """
[2025-06-11 08:29:40] production.ERROR: file_put_contents(/var/www/mp2go/storage/framework/sessions/vfN1Bl8n8b4eUpQRCQuAcymROtTHUpeu5mvU7heH): failed to open stream: Permission denied {"exception":"[object] (ErrorException(code: 0): file_put_contents(/var/www/mp2go/storage/framework/sessions/vfN1Bl8n8b4eUpQRCQuAcymROtTHUpeu5mvU7heH): failed to open stream: Permission denied at /var/www/mp2go/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:122)\n
[stacktrace]\n
#0 [internal function]: Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(2, 'file_put_conten...', '/var/www/mp2go/...', 122, Array)\n
#1 /var/www/mp2go/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php(122): file_put_contents('/var/www/mp2go/...', 'a:4:{s:6:\"_toke...', 2)\n
#2 /var/www/mp2go/vendor/laravel/framework/src/Illuminate/Session/FileSessionHandler.php(83): Illuminate\\Filesystem\\Filesystem->put('/var/www/mp2go/...', 'a:4:{s:6:\"_toke...', true)\n
#3 /var/www/mp2go/vendor/laravel/framework/src/Illuminate/Session/Store.php(129): Illuminate\\Session\\FileSessionHandler->write('vfN1Bl8n8b4eUpQ...', 'a:4:{s:6:\"_toke...')\n
#4 /var/www/mp2go/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(87): Illuminate\\Session\\Store->save()\n
#5 /var/www/mp2go/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(218): Illuminate\\Session\\Middleware\\StartSession->terminate(Object(Illuminate\\Http\\Request), Object(Illuminate\\Http\\Response))\n
#6 /var/www/mp2go/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(189): Illuminate\\Foundation\\Http\\Kernel->terminateMiddleware(Object(Illuminate\\Http\\Request), Object(Illuminate\\Http\\Response))\n
#7 /var/www/mp2go/public/index.php(79): Illuminate\\Foundation\\Http\\Kernel->terminate(Object(Illuminate\\Http\\Request), Object(Illuminate\\Http\\Response))\n
#8 {main}\n
"} \n
"""
]
* @param array $context The log context
* @return bool Whether the record has been processed
*/
public function err($message, array $context = array())
{
return $this->addRecord(static::ERROR, $message, $context);
}
/**
* Adds a log record at the ERROR level.
*
* This method allows for compatibility with common interfaces.
*
* @param string $message The log message
* @param array $context The log context
* @return bool Whether the record has been processed
*/
public function error($message, array $context = array())
{
return $this->addRecord(static::ERROR, $message, $context);
}
/**
* Adds a log record at the CRITICAL level.
*
* This method allows for compatibility with common interfaces.
*
* @param string $message The log message
* @param array $context The log context
* @return bool Whether the record has been processed
*/
public function crit($message, array $context = array())
{
return $this->addRecord(static::CRITICAL, $message, $context);
}
/**
* Adds a log record at the CRITICAL level.
*
* This method allows for compatibility with common interfaces.
Arguments
400
"file_put_contents(/var/www/mp2go/storage/framework/sessions/vfN1Bl8n8b4eUpQRCQuAcymROtTHUpeu5mvU7heH): failed to open stream: Permission denied"
array:1 [
"exception" => ErrorException {#35
#message: "file_put_contents(/var/www/mp2go/storage/framework/sessions/vfN1Bl8n8b4eUpQRCQuAcymROtTHUpeu5mvU7heH): failed to open stream: Permission denied"
#code: 0
#file: "/var/www/mp2go/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php"
#line: 122
#severity: E_WARNING
}
]
* @return void
*/
public function write($level, $message, array $context = [])
{
$this->writeLog($level, $message, $context);
}
/**
* Write a message to the log.
*
* @param string $level
* @param string $message
* @param array $context
* @return void
*/
protected function writeLog($level, $message, $context)
{
$this->fireLogEvent($level, $message = $this->formatMessage($message), $context);
$this->logger->{$level}($message, $context);
}
/**
* Register a new callback handler for when a log event is triggered.
*
* @param \Closure $callback
* @return void
*
* @throws \RuntimeException
*/
public function listen(Closure $callback)
{
if (! isset($this->dispatcher)) {
throw new RuntimeException('Events dispatcher has not been set.');
}
$this->dispatcher->listen(MessageLogged::class, $callback);
}
/**
Arguments
"file_put_contents(/var/www/mp2go/storage/framework/sessions/vfN1Bl8n8b4eUpQRCQuAcymROtTHUpeu5mvU7heH): failed to open stream: Permission denied"
array:1 [
"exception" => ErrorException {#35
#message: "file_put_contents(/var/www/mp2go/storage/framework/sessions/vfN1Bl8n8b4eUpQRCQuAcymROtTHUpeu5mvU7heH): failed to open stream: Permission denied"
#code: 0
#file: "/var/www/mp2go/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php"
#line: 122
#severity: E_WARNING
}
]
*
* @param string $message
* @param array $context
* @return void
*/
public function critical($message, array $context = [])
{
$this->writeLog(__FUNCTION__, $message, $context);
}
/**
* Log an error message to the logs.
*
* @param string $message
* @param array $context
* @return void
*/
public function error($message, array $context = [])
{
$this->writeLog(__FUNCTION__, $message, $context);
}
/**
* Log a warning message to the logs.
*
* @param string $message
* @param array $context
* @return void
*/
public function warning($message, array $context = [])
{
$this->writeLog(__FUNCTION__, $message, $context);
}
/**
* Log a notice to the logs.
*
* @param string $message
* @param array $context
* @return void
Arguments
"error"
"file_put_contents(/var/www/mp2go/storage/framework/sessions/vfN1Bl8n8b4eUpQRCQuAcymROtTHUpeu5mvU7heH): failed to open stream: Permission denied"
array:1 [
"exception" => ErrorException {#35
#message: "file_put_contents(/var/www/mp2go/storage/framework/sessions/vfN1Bl8n8b4eUpQRCQuAcymROtTHUpeu5mvU7heH): failed to open stream: Permission denied"
#code: 0
#file: "/var/www/mp2go/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php"
#line: 122
#severity: E_WARNING
}
]
*
* @return void
*/
public function critical($message, array $context = [])
{
return $this->driver()->critical($message, $context);
}
/**
* Runtime errors that do not require immediate action but should typically
* be logged and monitored.
*
* @param string $message
* @param array $context
*
* @return void
*/
public function error($message, array $context = [])
{
return $this->driver()->error($message, $context);
}
/**
* Exceptional occurrences that are not errors.
*
* Example: Use of deprecated APIs, poor use of an API, undesirable things
* that are not necessarily wrong.
*
* @param string $message
* @param array $context
*
* @return void
*/
public function warning($message, array $context = [])
{
return $this->driver()->warning($message, $context);
}
/**
* Normal but significant events.
Arguments
"file_put_contents(/var/www/mp2go/storage/framework/sessions/vfN1Bl8n8b4eUpQRCQuAcymROtTHUpeu5mvU7heH): failed to open stream: Permission denied"
array:1 [
"exception" => ErrorException {#35
#message: "file_put_contents(/var/www/mp2go/storage/framework/sessions/vfN1Bl8n8b4eUpQRCQuAcymROtTHUpeu5mvU7heH): failed to open stream: Permission denied"
#code: 0
#file: "/var/www/mp2go/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php"
#line: 122
#severity: E_WARNING
}
]
*/
public function report(Exception $e)
{
if ($this->shouldntReport($e)) {
return;
}
if (method_exists($e, 'report')) {
return $e->report();
}
try {
$logger = $this->container->make(LoggerInterface::class);
} catch (Exception $ex) {
throw $e;
}
$logger->error(
$e->getMessage(),
array_merge($this->context(), ['exception' => $e]
));
}
/**
* Determine if the exception should be reported.
*
* @param \Exception $e
* @return bool
*/
public function shouldReport(Exception $e)
{
return ! $this->shouldntReport($e);
}
/**
* Determine if the exception is in the "do not report" list.
*
* @param \Exception $e
* @return bool
*/
Arguments
"file_put_contents(/var/www/mp2go/storage/framework/sessions/vfN1Bl8n8b4eUpQRCQuAcymROtTHUpeu5mvU7heH): failed to open stream: Permission denied"
array:1 [
"exception" => ErrorException {#35
#message: "file_put_contents(/var/www/mp2go/storage/framework/sessions/vfN1Bl8n8b4eUpQRCQuAcymROtTHUpeu5mvU7heH): failed to open stream: Permission denied"
#code: 0
#file: "/var/www/mp2go/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php"
#line: 122
#severity: E_WARNING
}
]
}
/**
* Handle an uncaught exception from the application.
*
* Note: Most exceptions can be handled via the try / catch block in
* the HTTP and Console kernels. But, fatal error exceptions must
* be handled differently since they are not normal exceptions.
*
* @param \Throwable $e
* @return void
*/
public function handleException($e)
{
if (! $e instanceof Exception) {
$e = new FatalThrowableError($e);
}
try {
$this->getExceptionHandler()->report($e);
} catch (Exception $e) {
//
}
if ($this->app->runningInConsole()) {
$this->renderForConsole($e);
} else {
$this->renderHttpResponse($e);
}
}
/**
* Render an exception to the console.
*
* @param \Exception $e
* @return void
*/
protected function renderForConsole(Exception $e)
{
$this->getExceptionHandler()->renderForConsole(new ConsoleOutput, $e);
Arguments
ErrorException {#35
#message: "file_put_contents(/var/www/mp2go/storage/framework/sessions/vfN1Bl8n8b4eUpQRCQuAcymROtTHUpeu5mvU7heH): failed to open stream: Permission denied"
#code: 0
#file: "/var/www/mp2go/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php"
#line: 122
#severity: E_WARNING
}
Arguments
ErrorException {#35
#message: "file_put_contents(/var/www/mp2go/storage/framework/sessions/vfN1Bl8n8b4eUpQRCQuAcymROtTHUpeu5mvU7heH): failed to open stream: Permission denied"
#code: 0
#file: "/var/www/mp2go/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php"
#line: 122
#severity: E_WARNING
}