2010-01-11 12:07:28 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class Log
|
|
|
|
{
|
|
|
|
|
|
|
|
function __construct($name='ykval')
|
|
|
|
{
|
|
|
|
$this->name=$name;
|
2010-01-14 11:25:17 +00:00
|
|
|
$this->fields=array();
|
2010-01-11 12:07:28 +00:00
|
|
|
}
|
2010-01-14 11:25:17 +00:00
|
|
|
|
|
|
|
function addField($name, $value)
|
|
|
|
{
|
|
|
|
$this->fields[$name]=$value;
|
|
|
|
}
|
|
|
|
|
2010-01-11 12:07:28 +00:00
|
|
|
function log($priority, $message, $arr=null){
|
|
|
|
if (is_array($arr)) {
|
|
|
|
foreach($arr as $key=>$value){
|
|
|
|
$message.=" $key=$value ";
|
|
|
|
}
|
|
|
|
}
|
2010-01-14 11:25:17 +00:00
|
|
|
# Add fields
|
|
|
|
$msg_fields = "";
|
|
|
|
foreach ($this->fields as $field=>$value) {
|
|
|
|
$mes_fields .= "[" . $value . "] ";
|
|
|
|
}
|
|
|
|
syslog($priority, $this->name . ':' . $msg_fields . $message);
|
2010-01-11 12:07:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|