Log_Syslog
extends Kohana_Log_Syslog
extends Log_Writer
extends Kohana_Log_Writer
Syslog log writer.
Information
This class is a transparent base class for Kohana_Log_Syslog
Constants
- None
Properties
Properties
-
public static int $strace_level
-
Level to use for stack traces
-
integer 6
-
public static string $timestamp
-
timestamp format for log entries.
Defaults to Date::$timestamp_format
-
NULL
-
public static string $timezone
-
timezone for log entries
Defaults to Date::$timezone, which defaults to date_default_timezone_get()
-
NULL
-
protected string $_ident
-
The syslog identifier
-
Default value:
NULL
-
protected array $_log_levels
-
Numeric log level to string lookup table.
-
Default value:
array(4) ( 1 => string(8) "CRITICAL" 4 => string(5) "ERROR" 5 => string(7) "WARNING" 6 => string(5) "DEBUG" )
Methods
public __construct([ string $ident = string(9) "KohanaPHP" , int $facility = integer 8 ] ) (defined in Kohana_Log_Syslog)
Creates a new syslog logger.
Parameters
- string $ident = string(9) "KohanaPHP" - Syslog identifier
- int $facility = integer 8 - Facility to log to
Tags
Return Values
- void
Source Code
public function __construct($ident = 'KohanaPHP', $facility = LOG_USER)
{
$this->_ident = $ident;
// Open the connection to syslog
openlog($this->_ident, LOG_CONS, $facility);
}
public __destruct() (defined in Kohana_Log_Syslog)
Closes the syslog connection
Return Values
- void
Source Code
public function __destruct()
{
// Close connection to syslog
closelog();
}
public write(array $messages ) (defined in Kohana_Log_Syslog)
Writes each of the messages into the syslog.
Parameters
- array $messages required - $messages
Return Values
- void
Source Code
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());
}
}
}
final public __toString() (defined in Kohana_Log_Writer)
Allows the writer to have a unique key when stored.
echo $writer;
Return Values
- string
Source Code
final public function __toString()
{
return spl_object_hash($this);
}
public format_message(array $message [, string $format = string(33) "time --- level: body in file:line" ] ) (defined in Kohana_Log_Writer)
Formats a log entry.
Parameters
- array $message required - $message
- string $format = string(33) "time --- level: body in file:line" - $format
Return Values
- string
Source Code
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;
}