Xataface 2.0
Xataface Application Framework
Dataface/Logger.php
Go to the documentation of this file.
00001 <?php
00006 class Dataface_Logger {
00007         private $items = array();
00008         private $format='html';
00009         
00010         public function setFormat($format){
00011                 $this->format = $format;
00012         }
00013         public function log($str, $level=0){
00014                 $this->items[] = array('message'=>$str, 'level'=>$level);
00015         }
00016         public function clear(){
00017                 $this->items = array();
00018         }
00019         
00020         public function items($level=0){
00021                 $out = array();
00022                 foreach ($this->items as $i){
00023                         if ( $i['level'] >= $level ) $out[] = $i;
00024                 }
00025                 return $out;
00026         }
00027         
00028         public function dump($level=0, $separator = "\n"){
00029                 $messages = array();
00030                 foreach ($this->items($level) as $i){
00031                         $messages[] = $i['message'];
00032                 }
00033                 if ( $this->format == 'html' ){
00034                         $messages = array_map('htmlspecialchars', $messages);
00035                 }
00036                 
00037                 echo implode($separator, $messages);
00038         }
00039         
00040 }
 All Data Structures Namespaces Files Functions Variables Enumerations