names = array('ERROR ', 'WARNING', 'INFO ', 'DEBUG ', 'VERBOSE'); $this->runlevel = $runlevel; $this->printout = $printout; } function log($msg, $runlevel=Null) { if($runlevel === Null) $runlevel = LOGGING_INFO; $data[] = array($this->runlevel, $msg); if($this->printout and $runlevel <= $this->runlevel) print "{$this->names[$runlevel]}: $msg\n"; } function printout($clear=True, $runlevel=Null) { if(!$runlevel) $runlevel = $this->runlevel; foreach($this->data as $data) { if($runlevel <= $data[0]) print "{$this->names[$runlevel]}: $data[1]\n"; } if($clear) $this->data = array(); } } ?>