Files
thetool/lib/mvcfronk/mfLog/mfLoghandler.php
Frank Schubert 4ea4927931 Initial commit
2021-03-29 23:04:42 +02:00

45 lines
904 B
PHP

<?php
class mfLoghandler {
public static $instance;
private $logtype="file";
private $log;
private function __construct() {
$this->initLog();
}
public static function singleton() {
if(!isset(self::$instance)) {
$c=__CLASS__;
self::$instance=new $c();
}
return self::$instance;
}
private function initLog() {
if(defined('LOGTYPE')) {
$this->logtype=LOGTYPE;
}
$type=ucfirst($this->logtype);
require_once(LIBDIR."/mvcfronk/mfLog/mfLog_$type.php");
$logclass="mfLog_$type";
$this->log=new $logclass();
$this->log->init();
}
public function write($message,$severity="warn") {
if(!method_exists($this->log, "write")) {
throw new Exception(__CLASS__.": Logging class does not implement write function!");
}
$this->log->write($message,$severity);
}
public function __call($severity,$message) {
$this->write($message[0],$severity);
}
}