40 'critical' => LOG_CRIT,
46 'notice' => LOG_NOTICE,
48 'warn' => LOG_WARNING,
49 'warning' => LOG_WARNING,
55 'authpriv' => LOG_AUTHPRIV,
57 'daemon' => LOG_DAEMON,
62 'syslog' => LOG_SYSLOG,
80 'WARNING' =>
'warning',
82 'CRITICAL' =>
'critical',
84 'EMERGENCY' =>
'emergency',
119 if (defined(
'LOG_LOCAL0') && !isset(static::$facilityNames[
'local0'])) {
120 static::$facilityNames += array(
121 'local0' => LOG_LOCAL0,
122 'local1' => LOG_LOCAL1,
123 'local2' => LOG_LOCAL2,
124 'local3' => LOG_LOCAL3,
125 'local4' => LOG_LOCAL4,
126 'local5' => LOG_LOCAL5,
127 'local6' => LOG_LOCAL6,
128 'local7' => LOG_LOCAL7,
132 parent::__construct();
136 if ($this->socket ===
false) {
137 throw new \Plop\Exception(
'Unable to connect to the syslog');
158 return stream_socket_client($this->address);
179 if (is_string($priority)) {
180 $priority = static::$priorityNames[$priority];
193 if ($this->socket !==
false) {
194 fclose($this->socket);
195 $this->socket =
false;
212 if (isset(static::$priorityMap[$levelName])) {
213 return static::$priorityMap[$levelName];
221 $msg = $this->
format($record);
223 static::LOG_FORMAT_STRING,
231 for ($written = 0; $written < strlen($msg); $written += $fwrite) {
232 $fwrite = @fwrite($this->socket, substr($msg, $written));
233 if ($fwrite ===
false) {
emit(\Plop\RecordInterface $record)
$facility
The facility to use when logging the messages.
An abstract class that can be used as a base to create new log records handlers.
Interface for a log record.
__construct($address=self::DEFAULT_ADDRESS, $facility=LOG_USER)
format(\Plop\RecordInterface $record)
static $facilityNames
Mapping between the facility names and their associated constant.
handleError(\Plop\RecordInterface $record,\Exception $exception)
$socket
The socket that will be used to send the logs.
static $priorityNames
Mapping between Plop's log levels and the syslog ones.
const DEFAULT_ADDRESS
Default address for the system logs.
__destruct()
Free the resources used by this handler.
This exception is thrown by Plop whenever a problem is detected.
encodePriority($facility, $priority)
$address
Address of the syslog where the logs will be sent.
const LOG_FORMAT_STRING
Specific format string used for system logs.
An handler that sends log messages to the system logs (syslog).