This class is a transparent base class for Log_Syslog and should not be accessed directly.
Syslog log writer.
Class declared in SYSPATH/classes/Kohana/Log/Syslog.php on line 12.
int
$strace_levelLevel to use for stack traces
integer 7
string
$timestamptimestamp format for log entries.
Defaults to Date::$timestamp_format
NULL
string
$timezonetimezone for log entries
Defaults to Date::$timezone, which defaults to date_default_timezone_get()
NULL
string
$_identThe syslog identifier
NULL
array
$_log_levelsNumeric log level to string lookup table.
array(8) ( 0 => string(9) "EMERGENCY" 1 => string(5) "ALERT" 2 => string(8) "CRITICAL" 3 => string(5) "ERROR" 4 => string(7) "WARNING" 5 => string(6) "NOTICE" 6 => string(4) "INFO" 7 => string(5) "DEBUG" )
Creates a new syslog logger.
string
$ident
= string(9) "KohanaPHP" - Syslog identifier int
$facility
= integer 8 - Facility to log to void
public function __construct($ident = 'KohanaPHP', $facility = LOG_USER)
{
$this->_ident = $ident;
// Open the connection to syslog
openlog($this->_ident, LOG_CONS, $facility);
}
Closes the syslog connection
void
public function __destruct()
{
// Close connection to syslog
closelog();
}
Writes each of the messages into the syslog.
array
$messages
required - $messages void
public function write(array $messages)
{
foreach ($messages as $message) {
syslog($message['level'], $message['body']);
if (isset($message['additional']['exception'])) {
syslog(Log_Writer::$strace_level, $message['additional']['exception']->getTraceAsString());
}
}
}
Allows the writer to have a unique key when stored.
echo $writer;
string
final public function __toString()
{
return spl_object_hash($this);
}
Formats a log entry.
array
$message
required - $message string
$format
= string(33) "time --- level: body in file:line" - $format string
public function format_message(array $message, $format = "time --- level: body in file:line")
{
$message['time'] = Date::formatted_time('@' . $message['time'], Log_Writer::$timestamp, Log_Writer::$timezone, true);
$message['level'] = $this->_log_levels[$message['level']];
$string = strtr($format, array_filter($message, 'is_scalar'));
if (isset($message['additional']['exception'])) {
// Re-use as much as possible, just resetting the body to the trace
$message['body'] = $message['additional']['exception']->getTraceAsString();
$message['level'] = $this->_log_levels[Log_Writer::$strace_level];
$string .= PHP_EOL . strtr($format, array_filter($message, 'is_scalar'));
}
return $string;
}