2016-10-19 15:29:51 +02:00
|
|
|
<?php
|
|
|
|
/* Icinga Web 2 | (c) 2016 Icinga Development Team | GPLv2+ */
|
|
|
|
|
|
|
|
namespace Icinga\Application\Logger\Writer;
|
|
|
|
|
|
|
|
use Icinga\Application\Logger;
|
|
|
|
use Icinga\Application\Logger\LogWriter;
|
2016-11-03 12:16:48 +01:00
|
|
|
use Icinga\Exception\NotWritableError;
|
2016-10-19 15:29:51 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Log to the webserver log, a file or syslog
|
|
|
|
*
|
|
|
|
* @see https://secure.php.net/manual/en/errorfunc.configuration.php#ini.error-log
|
|
|
|
*/
|
|
|
|
class PhpWriter extends LogWriter
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
2016-11-03 12:01:03 +01:00
|
|
|
public function log($severity, $message)
|
|
|
|
{
|
2016-11-03 12:16:48 +01:00
|
|
|
if (! error_log(Logger::$levels[$severity] . ' - ' . str_replace("\n", ' ', $message))) {
|
|
|
|
throw new NotWritableError('Could not log to ' . (ini_get('error_log') ?: 'SAPI'));
|
|
|
|
}
|
2016-10-19 15:29:51 +02:00
|
|
|
}
|
|
|
|
}
|