Class SyslogLog
Syslog stream for Logging. Writes logs to the system logger
- BaseLog implements CakeLogInterface
- SyslogLog
Copyright: Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
License: MIT License
Location: Cake/Log/Engine/SyslogLog.php
Properties summary
-
$_defaults
protectedarray
-
$_open
protectedboolean
Whether the logger connection is open or not -
$_priorityMap
protectedarray
Inherited Properties
Method Summary
-
__construct() public
Make sure the configuration contains the format parameter, by default it uses the error number and the type as a prefix to the message
-
__destruct() public
Closes the logger connection -
_open() protected
Extracts the call to openlog() in order to run unit tests on it. This function will initialize the connection to the system logger
-
_write() protected
Extracts the call to syslog() in order to run unit tests on it. This function will perform the actual write in the system logger
-
write() public
Writes a message to syslog
Method Detail
__construct() public ¶
__construct( array $config = array() )
Make sure the configuration contains the format parameter, by default it uses the error number and the type as a prefix to the message
Parameters
- array $config optional array()
Overrides
_open() protected ¶
_open( string $ident , integer $options , integer $facility )
Extracts the call to openlog() in order to run unit tests on it. This function will initialize the connection to the system logger
Parameters
- string $ident
- the prefix to add to all messages logged
- integer $options
- the options flags to be used for logged messages
- integer $facility
- the stream or facility to log to
_write() protected ¶
_write( integer $priority , string $message )
Extracts the call to syslog() in order to run unit tests on it. This function will perform the actual write in the system logger
Parameters
- integer $priority
- string $message
Returns
write() public ¶
write( string $type , string $message )
Writes a message to syslog
Map the $type back to a LOG_ constant value, split multi-line messages into multiple log messages, pass all messages through the format defined in the configuration
Parameters
- string $type
- The type of log you are making.
- string $message
- The message you want to log.
Returns
success of write.
Methods inherited from BaseLog
config() public ¶
config( array $config = array() )
Sets instance config. When $config is null, returns config array
Config
types
string or array, levels the engine is interested inscopes
string or array, scopes the engine is interested in
Parameters
- array $config optional array()
- engine configuration
Returns
Properties detail
$_defaults ¶
By default messages are formatted as: type: message
To override the log format (e.g. to add your own info) define the format key when configuring this logger
If you wish to include a prefix to all messages, for instance to identify the application or the web server, then use the prefix option. Please keep in mind the prefix is shared by all streams using syslog, as it is dependent of the running process. For a local prefix, to be used only by one stream, you can use the format key.
Example:
{{{ CakeLog::config('error', array( 'engine' => 'Syslog', 'types' => array('emergency', 'alert', 'critical', 'error'), 'format' => "%s: My-App - %s", 'prefix' => 'Web Server 01' )); }}}
array( 'format' => '%s: %s', 'flag' => LOG_ODELAY, 'prefix' => '', 'facility' => LOG_USER )
$_priorityMap ¶
Used to map the string names back to their LOG_* constants
array( 'emergency' => LOG_EMERG, 'alert' => LOG_ALERT, 'critical' => LOG_CRIT, 'error' => LOG_ERR, 'warning' => LOG_WARNING, 'notice' => LOG_NOTICE, 'info' => LOG_INFO, 'debug' => LOG_DEBUG )