1: <?php
2: /**
3: * CSysLogRoute class file.
4: *
5: * @author miramir <gmiramir@gmail.com>
6: * @author resurtm <resurtm@gmail.com>
7: * @link http://www.yiiframework.com/
8: * @copyright 2008-2014 Yii Software LLC
9: * @license http://www.yiiframework.com/license/
10: */
11:
12: /**
13: * CSysLogRoute dumps log messages to syslog.
14: *
15: * @author miramir <gmiramir@gmail.com>
16: * @author resurtm <resurtm@gmail.com>
17: * @package system.logging
18: * @since 1.1.16
19: */
20: class CSysLogRoute extends CLogRoute
21: {
22: /**
23: * @var string syslog identity name.
24: */
25: public $identity;
26: /**
27: * @var integer syslog facility name.
28: */
29: public $facility=LOG_SYSLOG;
30:
31: /**
32: * Sends log messages to syslog.
33: * @param array $logs list of log messages.
34: */
35: protected function processLogs($logs)
36: {
37: static $syslogLevels=array(
38: CLogger::LEVEL_TRACE=>LOG_DEBUG,
39: CLogger::LEVEL_WARNING=>LOG_WARNING,
40: CLogger::LEVEL_ERROR=>LOG_ERR,
41: CLogger::LEVEL_INFO=>LOG_INFO,
42: CLogger::LEVEL_PROFILE=>LOG_DEBUG,
43: );
44:
45: openlog($this->identity,LOG_ODELAY|LOG_PID,$this->facility);
46: foreach($logs as $log)
47: syslog($syslogLevels[$log[1]],$this->formatLogMessage(str_replace("\n",', ',$log[0]),$log[1],$log[2],$log[3]));
48: closelog();
49: }
50: }
51: