mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-10 15:14:14 +02:00
Merge pull request #343 from pankaj-garg/filePermissions
option to set file permissions in rotatingFileHandler
This commit is contained in:
@@ -36,8 +36,9 @@ class RotatingFileHandler extends StreamHandler
|
|||||||
* @param integer $maxFiles The maximal amount of files to keep (0 means unlimited)
|
* @param integer $maxFiles The maximal amount of files to keep (0 means unlimited)
|
||||||
* @param integer $level The minimum logging level at which this handler will be triggered
|
* @param integer $level The minimum logging level at which this handler will be triggered
|
||||||
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
|
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
|
||||||
|
* @param int $filePermissions Optional file permissions (default (0644) are only for owner read/write)
|
||||||
*/
|
*/
|
||||||
public function __construct($filename, $maxFiles = 0, $level = Logger::DEBUG, $bubble = true)
|
public function __construct($filename, $maxFiles = 0, $level = Logger::DEBUG, $bubble = true, $filePermission = 0644)
|
||||||
{
|
{
|
||||||
$this->filename = $filename;
|
$this->filename = $filename;
|
||||||
$this->maxFiles = (int) $maxFiles;
|
$this->maxFiles = (int) $maxFiles;
|
||||||
@@ -45,7 +46,7 @@ class RotatingFileHandler extends StreamHandler
|
|||||||
$this->filenameFormat = '{filename}-{date}';
|
$this->filenameFormat = '{filename}-{date}';
|
||||||
$this->dateFormat = 'Y-m-d';
|
$this->dateFormat = 'Y-m-d';
|
||||||
|
|
||||||
parent::__construct($this->getTimedFilename(), $level, $bubble);
|
parent::__construct($this->getTimedFilename(), $level, $bubble, $filePermission);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -25,13 +25,15 @@ class StreamHandler extends AbstractProcessingHandler
|
|||||||
protected $stream;
|
protected $stream;
|
||||||
protected $url;
|
protected $url;
|
||||||
private $errorMessage;
|
private $errorMessage;
|
||||||
|
protected $filePermission;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $stream
|
* @param string $stream
|
||||||
* @param integer $level The minimum logging level at which this handler will be triggered
|
* @param integer $level The minimum logging level at which this handler will be triggered
|
||||||
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
|
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
|
||||||
|
* @param int $filePermissions Optional file permissions (default (0644) are only for owner read/write)
|
||||||
*/
|
*/
|
||||||
public function __construct($stream, $level = Logger::DEBUG, $bubble = true)
|
public function __construct($stream, $level = Logger::DEBUG, $bubble = true, $filePermission = 0644)
|
||||||
{
|
{
|
||||||
parent::__construct($level, $bubble);
|
parent::__construct($level, $bubble);
|
||||||
if (is_resource($stream)) {
|
if (is_resource($stream)) {
|
||||||
@@ -39,6 +41,8 @@ class StreamHandler extends AbstractProcessingHandler
|
|||||||
} else {
|
} else {
|
||||||
$this->url = $stream;
|
$this->url = $stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->filePermission = $filePermission;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -64,6 +68,7 @@ class StreamHandler extends AbstractProcessingHandler
|
|||||||
$this->errorMessage = null;
|
$this->errorMessage = null;
|
||||||
set_error_handler(array($this, 'customErrorHandler'));
|
set_error_handler(array($this, 'customErrorHandler'));
|
||||||
$this->stream = fopen($this->url, 'a');
|
$this->stream = fopen($this->url, 'a');
|
||||||
|
@chmod($this->url, $this->filePermission);
|
||||||
restore_error_handler();
|
restore_error_handler();
|
||||||
if (!is_resource($this->stream)) {
|
if (!is_resource($this->stream)) {
|
||||||
$this->stream = null;
|
$this->stream = null;
|
||||||
|
Reference in New Issue
Block a user