migrated classes to php5, fixed issues #12 and #14, added full error_reporting to examples

git-svn-id: svn://netflint.net/xmpphp@24 ef36c318-a008-4979-b6e8-6b496270793b
This commit is contained in:
temp
2008-04-28 22:05:31 +00:00
parent ef5ed5d3e1
commit ac78c821a0
6 changed files with 201 additions and 154 deletions

View File

@@ -19,34 +19,41 @@ along with XMPPHP; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
define('LOGGING_ERROR', 0);
define('LOGGING_WARNING', 1);
define('LOGGING_INFO', 2);
define('LOGGING_DEBUG', 3);
define('LOGGING_VERBOSE', 4);
class Logging {
var $data = array();
var $names = array();
var $runlevel;
var $printout;
const LOG_ERROR = 0;
const LOG_WARNING = 1;
const LOG_INFO = 2;
const LOG_DEBUG = 3;
const LOG_VERBOSE = 4;
protected $data = array();
protected $names = array('ERROR', 'WARNING', 'INFO', 'DEBUG', 'VERBOSE');
protected $runlevel;
protected $printout;
function Logging($printout = False, $runlevel=LOGGING_INFO) {
$this->names = array('ERROR ', 'WARNING', 'INFO ', 'DEBUG ', 'VERBOSE');
/**
* Constructor
*
* @param boolean $printout
* @param string $runlevel
*/
public function __construct($printout = false, $runlevel = self::LOG_INFO) {
$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";
public function log($msg, $runlevel = null) {
if($runlevel === null) $runlevel = self::LOG_INFO;
$this->data[] = array($this->runlevel, $msg);
if($this->printout and $runlevel <= $this->runlevel) echo "{$this->names[$runlevel]}: $msg\n";
}
function printout($clear=True, $runlevel=Null) {
if(!$runlevel) $runlevel = $this->runlevel;
public function printout($clear = true, $runlevel = null) {
if($runlevel === null) $runlevel = $this->runlevel;
foreach($this->data as $data) {
if($runlevel <= $data[0]) print "{$this->names[$runlevel]}: $data[1]\n";
if($runlevel <= $data[0]) echo "{$this->names[$runlevel]}: $data[1]\n";
}
if($clear) $this->data = array();
}