class SpotSec_Log_Adapter_Syslog implements SpotSec_Log_Adapter_Interface { /** * SpotSec_Log level constants mapping to syslog levels * * @var array * @access private */ private $_levels = array( SpotSec_Log::LEVEL_DEBUG => LOG_DEBUG, SpotSec_Log::LEVEL_ERROR => LOG_ERR, SpotSec_Log::LEVEL_INFO => LOG_INFO, SpotSec_Log::LEVEL_SEVERE => LOG_CRIT, SpotSec_Log::LEVEL_WARNING => LOG_WARNING ); public function __construct() { // define syslog related vars define_syslog_variables(); } /** * Open the storage resource. If the adapter supports buffering, this may not * actually open anything until it is time to flush the buffer. */ public function open($ident, $option, $facility) { @openlog($ident, $option, $facility); } /** * Write a message to the log. If the adapter supports buffering, the * message may or may not actually go into storage until the buffer is flushed. * * @param $fields Associative array, contains keys 'message' and 'level' at a minimum. */ public function write($fields) { // write to log @syslog($this->_levels[$fields['level']], $fields['message']); } /** * Close the log storage opened by the log adapter. If the adapter supports * buffering, all log data must be sent to the log before the storage is closed. */ public function close() { @closelog(); } /** * Sets an option specific to the implementation of the log adapter. * * @param $optionKey Key name for the option to be changed. Keys are adapter-specific * @param $optionValue New value to assign to the option */ public function setOption($optionKey, $optionValue); public function __destruct() { $this->close(); } }