Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/worker/src/Monolog/Handler
File: StreamHandler.php
<?php
[0] Fix | Delete
[1] Fix | Delete
/*
[2] Fix | Delete
* This file is part of the Monolog package.
[3] Fix | Delete
*
[4] Fix | Delete
* (c) Jordi Boggiano <j.boggiano@seld.be>
[5] Fix | Delete
*
[6] Fix | Delete
* For the full copyright and license information, please view the LICENSE
[7] Fix | Delete
* file that was distributed with this source code.
[8] Fix | Delete
*/
[9] Fix | Delete
[10] Fix | Delete
/**
[11] Fix | Delete
* Stores to any stream resource
[12] Fix | Delete
*
[13] Fix | Delete
* Can be used to store into php://stderr, remote and local files, etc.
[14] Fix | Delete
*
[15] Fix | Delete
* @author Jordi Boggiano <j.boggiano@seld.be>
[16] Fix | Delete
*/
[17] Fix | Delete
class Monolog_Handler_StreamHandler extends Monolog_Handler_AbstractProcessingHandler
[18] Fix | Delete
{
[19] Fix | Delete
protected $stream;
[20] Fix | Delete
protected $url;
[21] Fix | Delete
private $errorMessage;
[22] Fix | Delete
[23] Fix | Delete
/**
[24] Fix | Delete
* @param string $stream
[25] Fix | Delete
* @param integer $level The minimum logging level at which this handler will be triggered
[26] Fix | Delete
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
[27] Fix | Delete
*/
[28] Fix | Delete
public function __construct($stream, $level = Monolog_Logger::DEBUG, $bubble = true)
[29] Fix | Delete
{
[30] Fix | Delete
parent::__construct($level, $bubble);
[31] Fix | Delete
if (is_resource($stream)) {
[32] Fix | Delete
$this->stream = $stream;
[33] Fix | Delete
} else {
[34] Fix | Delete
$this->url = $stream;
[35] Fix | Delete
}
[36] Fix | Delete
}
[37] Fix | Delete
[38] Fix | Delete
/**
[39] Fix | Delete
* {@inheritdoc}
[40] Fix | Delete
*/
[41] Fix | Delete
public function close()
[42] Fix | Delete
{
[43] Fix | Delete
if (is_resource($this->stream)) {
[44] Fix | Delete
fclose($this->stream);
[45] Fix | Delete
}
[46] Fix | Delete
$this->stream = null;
[47] Fix | Delete
}
[48] Fix | Delete
[49] Fix | Delete
/**
[50] Fix | Delete
* {@inheritdoc}
[51] Fix | Delete
*/
[52] Fix | Delete
protected function write(array $record)
[53] Fix | Delete
{
[54] Fix | Delete
if (null === $this->stream) {
[55] Fix | Delete
if (!$this->url) {
[56] Fix | Delete
throw new LogicException('Missing stream url, the stream can not be opened. This may be caused by a premature call to close().');
[57] Fix | Delete
}
[58] Fix | Delete
$this->errorMessage = null;
[59] Fix | Delete
set_error_handler(array($this, 'customErrorHandler'));
[60] Fix | Delete
$this->stream = fopen($this->url, 'a');
[61] Fix | Delete
restore_error_handler();
[62] Fix | Delete
if (!is_resource($this->stream)) {
[63] Fix | Delete
$this->stream = null;
[64] Fix | Delete
throw new UnexpectedValueException(sprintf('The stream or file "%s" could not be opened: '.$this->errorMessage, $this->url));
[65] Fix | Delete
}
[66] Fix | Delete
}
[67] Fix | Delete
fwrite($this->stream, (string) $record['formatted']);
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
private function customErrorHandler($code, $msg)
[71] Fix | Delete
{
[72] Fix | Delete
$this->errorMessage = preg_replace('{^fopen\(.*?\): }', '', $msg);
[73] Fix | Delete
}
[74] Fix | Delete
}
[75] Fix | Delete
[76] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function