fusionpbx/resources/classes/event/handler/syslog.php

39 lines
810 B
PHP
Raw Normal View History

<?php
include_once('virtual.php');
2015-01-04 04:49:10 +01:00
class Syslog extends Event_Handler{
protected $ident;
protected $option;
protected $facility;
protected $priority;
function __construct($ident='fusionpbx', $option=(LOG_PID | LOG_PERROR), $facility=LOG_LOCAL0, $priority=LOG_INFO){
$this->ident = $ident;
$this->option = $option;
$this->facility = $facility;
$this->priority = $priority;
if ($_SESSION['event']['syslog']['enable'] <> 0){
openlog($ident, $option, $facility);
}
}
function __destruct(){
if ($_SESSION['event']['syslog']['enable'] <> 0){
closelog();
}
}
2015-01-04 04:49:10 +01:00
public function log_event($event_type, $params){
if ($_SESSION['event']['syslog']['enable'] <> 0){
$log = '' ;
foreach ($params as $k => $v) {
$log .= "[$k]=[$v] ";
}
syslog($priority, $log);
}
}
}