9 <tr id='ix-[id]' class='prio[prio] [hash]'>
10 <td class='time'><a href='#[id]'>[time]</a></td>
11 <td class='prio'><a href='#[id]'>[name] ([prio])</a></td>
12 <td class='message'>[message]</td>
13 <td class='label'><label for='[hash]' title='[hash]-count'></label></td>
19 protected function value($value){
20 if($value ===
null)
return '<i>null</i>';
21 if($value ===
false)
return '<i>false</i>';
22 if($value ===
true)
return '<i>true</i>';
23 if($value ===
'')
return '<i>[empty string]</i>';
25 (is_string($value) && preg_match(
'/(^\\s| {2,}|\\s$)/',$value) && ($value = htmlspecialchars($value))) ||
26 (strpos($value = htmlspecialchars(trim(str_replace(
"Array\n(",
'array(',print_r($value,
true)))),
"\n") !==
false)
31 protected function format($prio,$context){
32 $this->_lastInsertId = $id = \Rsi\Str::random();
33 $result =
"<tr><td colspan='2'><a name='$id'>{$this->separator}</a></td></tr>\n";
34 foreach($context as $key => $value){
35 if($special = substr($key,0,1) ==
'*') $key = substr($key,1);
36 $class = ($special ?
'special ' :
'') . preg_replace(
'/\\W+/',
'-',$key);
37 if(($descr = $key) ==
'date/time') $descr =
"<a href='#ix-$id'>$descr</a>";
42 foreach($value as $record)
if(!is_array($record) || ($keys && (array_keys($record) !== $keys))){
46 else $keys = array_keys($record);
48 $html .=
"\t\t<tr><th></th><th>" . implode(
'</th><th>',array_map(
'htmlspecialchars',$keys)) .
"</th></tr>\n";
49 foreach($value as $index => $record){
50 $html .=
"\t\t<tr><th>" . htmlspecialchars($index) .
"</th>";
51 foreach($record as $data) $html .=
52 "<td" . (is_scalar($data) && preg_match(
'/^[\\d\\-:\\s]+$/',$data) ?
" class='number'" :
'') .
">" . $this->
value($data) .
"</td>";
56 else foreach($value as $key => $data) $html .=
57 "\t\t<tr><th>" . htmlspecialchars($key) .
"</th><td>" . $this->
value($data) .
"</td></tr>\n";
58 $html .=
"\t</table>";
60 if(strlen($result .=
"<tr class='$class'>\n\t<th" . ($html ?
" title='$descr'" :
'') .
">$descr</th>\n\t<td>" . ($html ?: $this->
value($value)) .
"</td>\n</tr>\n") > $this->maxSize){
61 $result .=
"<tr class='more'><td colspan='2'>...</td><tr>\n";
68 public function add($prio,$message,$context){
69 parent::add($prio,$message,$context);
70 if($index = $this->indexFilename) \Rsi\File::write($index,strtr($this->templateIndex,[
71 '[id]' => $this->_lastInsertId,
72 '[time]' => $this->_lastInsertTime,
74 '[name]' => array_search($prio,$this->_log->constants()),
75 '[message]' => htmlspecialchars($message),
76 '[hash]' => str_replace(
'*',md5($prio . $message),$this->hashFormat)
81 return $this->filename .
'.index';