syslog.php 802 B

123456789101112131415161718192021222324252627282930313233343536
  1. include_once('virtual.php');
  2. class Syslog extends Event_Handler{
  3. protected $ident;
  4. protected $option;
  5. protected $facility;
  6. protected $priority;
  7. function __construct($ident='fusionpbx', $option=(LOG_PID | LOG_PERROR), $facility=LOG_LOCAL0, $priority=LOG_INFO){
  8. $this->ident = $ident;
  9. $this->option = $option;
  10. $this->facility = $facility;
  11. $this->priority = $priority;
  12. if ($_SESSION['event']['syslog']['enable'] <> 0){
  13. openlog($ident, $option, $facility);
  14. }
  15. }
  16. function __destruct(){
  17. if ($_SESSION['event']['syslog']['enable'] <> 0){
  18. closelog();
  19. }
  20. }
  21. public function log_event($event_type, $params){
  22. if ($_SESSION['event']['syslog']['enable'] <> 0){
  23. $log = '' ;
  24. foreach ($params as $k => $v) {
  25. $log .= "[$k]=[$v] ";
  26. }
  27. syslog($priority, $log);
  28. }
  29. }
  30. }