Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/lib/jabber/XMPP/Log.php
Go to the documentation of this file.
00001 <?php
00039 class XMPPHP_Log {
00040         
00041         const LEVEL_ERROR   = 0;
00042         const LEVEL_WARNING = 1;
00043         const LEVEL_INFO        = 2;
00044         const LEVEL_DEBUG   = 3;
00045         const LEVEL_VERBOSE = 4;
00046         
00050         protected $data = array();
00051 
00055         protected $names = array('ERROR', 'WARNING', 'INFO', 'DEBUG', 'VERBOSE');
00056 
00060         protected $runlevel;
00061 
00065         protected $printout;
00066 
00073         public function __construct($printout = false, $runlevel = self::LEVEL_INFO) {
00074                 $this->printout = (boolean)$printout;
00075                 $this->runlevel = (int)$runlevel;
00076         }
00077 
00085         public function log($msg, $runlevel = self::LEVEL_INFO) {
00086                 $time = time();
00087                 #$this->data[] = array($this->runlevel, $msg, $time);
00088                 if($this->printout and $runlevel <= $this->runlevel) {
00089                         $this->writeLine($msg, $runlevel, $time);
00090                 }
00091         }
00092 
00100         public function printout($clear = true, $runlevel = null) {
00101                 if($runlevel === null) {
00102                         $runlevel = $this->runlevel;
00103                 }
00104                 foreach($this->data as $data) {
00105                         if($runlevel <= $data[0]) {
00106                                 $this->writeLine($data[1], $runlevel, $data[2]);
00107                         }
00108                 }
00109                 if($clear) {
00110                         $this->data = array();
00111                 }
00112         }
00113         
00114         protected function writeLine($msg, $runlevel, $time) {
00115                 //echo date('Y-m-d H:i:s', $time)." [".$this->names[$runlevel]."]: ".$msg."\n";
00116                 echo $time." [".$this->names[$runlevel]."]: ".$msg."\n";
00117                 flush();
00118         }
00119 }
 All Data Structures Namespaces Files Functions Variables Enumerations