本文整理汇总了PHP中Monolog\Handler\StreamHandler::write方法的典型用法代码示例。如果您正苦于以下问题:PHP StreamHandler::write方法的具体用法?PHP StreamHandler::write怎么用?PHP StreamHandler::write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Monolog\Handler\StreamHandler
的用法示例。
在下文中一共展示了StreamHandler::write方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: write
/**
* {@inheritdoc}
*/
protected function write(array $record)
{
if ($this->url && !file_exists($this->url)) {
$this->stream = null;
}
parent::write($record);
}
示例2: write
/**
* {@inheritdoc}
*
* @author Jordi Boggiano <j.boggiano@seld.be>
*/
protected function write(array $record)
{
//check to see if the resource has anything written to it
if (!is_resource($this->stream)) {
if (!$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->errorMessage = null;
set_error_handler([$this, 'customErrorHandler']);
if (!file_exists($this->url)) {
$this->stream = fopen($this->url, 'a');
//write php line to it
fwrite($this->stream, (string) '<?php die("access denied!"); ?>' . "\n\n");
} else {
$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: ' . $this->errorMessage, $this->url));
}
}
parent::write($record);
}
示例3: write
protected function write(array $record)
{
parent::write($record);
if (is_resource($this->stream)) {
fflush($this->stream);
}
}
示例4: write
protected function write(array $record)
{
try {
parent::write($record);
} catch (\UnexpectedValueException $e) {
throw new \Exception(Filechecks::getErrorMessageMissingPermissions($this->url));
}
}
示例5: write
/**
* @{inheritDoc}
*
* @param $record array
* @return void
*/
public function write(array $record)
{
$logDir = $this->filesystem->getParentDirectory($this->url);
if (!$this->filesystem->isDirectory($logDir)) {
$this->filesystem->createDirectory($logDir, 0777);
}
parent::write($record);
}
示例6: write
/**
* {@inheritdoc}
*/
public function write(array $record)
{
// on the first record written, if the log is new, we should rotate (once per day)
if (null === $this->mustRotate) {
$this->mustRotate = !file_exists($this->url);
}
return parent::write($record);
}
示例7: write
/**
* @{inheritDoc}
*
* @param $record array
* @return void
*/
public function write(array $record)
{
$logDir = $this->filesystem->getParentDirectory($this->url);
if (!$this->filesystem->isDirectory($logDir)) {
$this->filesystem->createDirectory($logDir, DriverInterface::WRITEABLE_DIRECTORY_MODE);
}
parent::write($record);
}
示例8: write
/**
* {@inheritdoc}
*/
protected function write(array $record)
{
if (!file_exists($this->url)) {
touch($this->url);
// Create blank file
chmod($this->url, 0777);
}
parent::write($record);
}
示例9: write
/**
* {@inheritdoc}
*/
public function write(array $record)
{
if (!$this->url) {
$this->url = $this->getRealPath($this->generateLogFilename());
}
if (!is_dir(dirname($this->url))) {
mkdir(dirname($this->url), 0755, true);
}
parent::write($record);
}
示例10: write
/**
* {@inheritdoc}
*/
protected function write(array $record)
{
// on the first record written, if the log is new, we should rotate (once per day)
if (null === $this->mustRotate) {
$this->mustRotate = !file_exists($this->url);
}
if ($this->nextRotation < $record['datetime']) {
$this->mustRotate = true;
$this->close();
}
parent::write($record);
}
示例11: write
/**
* {@inheritDoc}
*
* If the file does not exist, it is created with 0777 permissions.
*/
public function write(array $record)
{
if (null === $this->stream) {
// From original monolog stream handler
if (!$this->url) {
throw new \LogicException('Missing stream url, the stream can not be opened. This may be caused by a premature call to close().');
}
// Make the directory, if it doesn't exist
$dir = dirname($this->url);
if (!is_dir($dir)) {
mkdir($dir, 0777, true);
}
// Make the file, if it doesn't exist
if (!file_exists($this->url)) {
if (touch($this->url)) {
chmod($this->url, 0777);
}
}
}
return parent::write($record);
}
示例12: write
public function write(array $record)
{
$record['formatted'] .= '<br/>';
parent::write($record);
}
示例13: testWriteInvalidResource
/**
* @expectedException UnexpectedValueException
*/
public function testWriteInvalidResource()
{
$handler = new StreamHandler('bogus://url');
@$handler->write(array('message' => 'test'));
}
示例14: write
/**
* {@inheritdoc}
*/
public function write(array $record)
{
$this->currentTimestamp = $record['datetime'];
if (null === $this->mustRotate) {
$this->mustRotate = !file_exists($this->url);
$this->nextRotation = $this->nextRotationTime($this->currentTimestamp);
}
if ($this->nextRotation < $this->currentTimestamp) {
$this->mustRotate = true;
$this->close();
}
parent::write($record);
}