Source for file NS_Syslog_Handler.php
Documentation is available at NS_Syslog_Handler.php
* nanoserv handlers - Syslog protocol handler
* Copyright (C) 2004-2010 Vincent Negrier aka. sIX <six@aegis-corp.org>
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
* Require the nanoserv core
require_once "nanoserv-compat/nanoserv.php";
* Syslog protocol handler handler class
* Get facility name from numerical code
case 16: return "local0";
case 17: return "local1";
case 18: return "local2";
case 19: return "local3";
case 20: return "local4";
case 21: return "local5";
case 22: return "local6";
case 23: return "local7";
* Get facility numerical code from name
case "local0": return 16;
case "local1": return 17;
case "local2": return 18;
case "local3": return 19;
case "local4": return 20;
case "local5": return 21;
case "local6": return 22;
case "local7": return 23;
final public function on_Read($from, $data) {
if (($data{0} !== "<") || (($p = strpos($data, ">")) === false)) return;
$pri = (int) substr($data, 1, $p - 1);
$this->on_Event($host, $pri >> 3, $pri & 7, $msg);
* Event called on new syslog event
abstract public function on_Event($host, $facility, $severity, $message);
|