'LOG_EMERG', LOG_ALERT => 'LOG_ALERT', LOG_CRIT => 'LOG_CRIT', LOG_ERR => 'LOG_ERR', LOG_WARNING => 'LOG_WARNING', LOG_NOTICE => 'LOG_NOTICE', LOG_INFO => 'LOG_INFO', LOG_DEBUG => 'LOG_DEBUG', ); private $fields = array(); public function __construct ($name = 'ykval') { $this->name = $name; openlog('ykval', LOG_PID, LOG_LOCAL0); } public function addField($name, $value) { $this->fields[$name] = $value; } public function log ($priority, $message, $arr=null) { if (is_array($arr)) { foreach($arr as $key => $value){ if (is_array($value)) { $value = implode(':', $value); } $message .= " $key=$value "; } } $fields = ''; foreach ($this->fields as $val) $fields .= "[$val] "; syslog($priority, $this->log_levels[$priority] . ':' . $this->name . ':' . $fields . $message); } }