mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-14 03:09:08 +00:00
44 lines
912 B
PHP
44 lines
912 B
PHP
|
<?php
|
||
|
|
||
|
class ryLogger {
|
||
|
|
||
|
public $enable = false;
|
||
|
private $logs;
|
||
|
private static $_instance = NULL;
|
||
|
|
||
|
public static function getInstance() {
|
||
|
if (self::$_instance === NULL)
|
||
|
self::$_instance = new ryLogger();
|
||
|
return self::$_instance;
|
||
|
}
|
||
|
|
||
|
function addLog($log, $indent=NULL) {
|
||
|
if ($indent !== NULL)
|
||
|
$this->log_indent += $indent;
|
||
|
if ($log) {
|
||
|
$tabs = str_repeat(" ", $this->log_indent);
|
||
|
$a = $tabs.str_replace("\n", "\n ".$tabs, $log);
|
||
|
$this->logs[] = '<font color="#00FF00">'.$a.'</font>';
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function addPrint($log, $color='#FFFF00') {
|
||
|
$this->logs[] = '<font color="'.$color.'">'.$log.'</font>';
|
||
|
}
|
||
|
|
||
|
function addError($log) {
|
||
|
$this->logs[] = '<font color="#FF5500"> ERROR: '.$log.'</font>';
|
||
|
}
|
||
|
|
||
|
function getLogs() {
|
||
|
$ret = '';
|
||
|
if ($this->logs && $this->enable)
|
||
|
$ret = "<b>Debug</b>\n\n".implode("\n", $this->logs);
|
||
|
$this->logs = array();
|
||
|
return $ret;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
?>
|