mirror of
https://github.com/sigmasternchen/webcli
synced 2025-03-15 06:08:54 +00:00
I guess I did some changes here too
This commit is contained in:
parent
9c49592378
commit
a4c9c28baf
1 changed files with 43 additions and 0 deletions
43
backend/errorManager.php
Normal file
43
backend/errorManager.php
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
require_once("config.php");
|
||||
|
||||
|
||||
abstract class errorType {
|
||||
const fatal = 0;
|
||||
const warning = 10;
|
||||
const server = 500;
|
||||
const client = 400;
|
||||
}
|
||||
|
||||
class errorManager {
|
||||
static public function log($sender, $message, $type = errorType::warning, $display = false, $cancelExecution = false) {
|
||||
$fh = fopen(LOG_FILE, "a");
|
||||
$stype = "";
|
||||
switch($type) {
|
||||
case errorType::fatal:
|
||||
$stype = "fatal error";
|
||||
break;
|
||||
case errorType::warning:
|
||||
$stype = "warning";
|
||||
break;
|
||||
case errorType::server:
|
||||
$stype = "server error";
|
||||
break;
|
||||
case errorType::client:
|
||||
$stype = "client error";
|
||||
break;
|
||||
default:
|
||||
$stype = "unknown error (" . $type . ")";
|
||||
break;
|
||||
}
|
||||
fwrite($fh, time() . " - " . $stype . " : " . $sender . ": " . $message . " --- " . ($display ? "display" : "no display") . " . " . ($cancelExecution ? "cancel execution" : "continue execution") . "\n");
|
||||
fclose($fh);
|
||||
|
||||
if ($display)
|
||||
echo "\n\n" . $stype . ": " . $sender . " says: " . $message . "\n\n";
|
||||
if ($cancelExecution)
|
||||
exit();
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in a new issue