Spaces:
Runtime error
Runtime error
File size: 1,048 Bytes
8d21059 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | <?php
# Error Reporting via Telegram Bot
# Work only if you set the log_chat in configs!
set_error_handler("errorHandler");
register_shutdown_function("shutdownHandler");
function errorHandler($error_type, $error, $error_file, $error_line, $error_context = '') {
global $bot;
if (isset($bot) and $bot->configs['log_chat'] and $error = error_get_last()) {
if ($bot->configs['log_types'][$error['type']]) {
$error_message = $error['message'] . PHP_EOL . 'File: ' . $bot->code($error['file']) . ' on line ' . $bot->code($error['line']);
$bot->sendLog($bot->bold('[Error]' . PHP_EOL) . $error_message);
}
}
}
function shutdownHandler() {
global $bot;
if (isset($bot) and $bot->configs['log_chat'] and $error = error_get_last()) {
if ($bot->configs['log_types'][$error['type']]) {
$error_message = $error['message'] . PHP_EOL . 'File: ' . $bot->code($error['file']) . ' on line ' . $bot->code($error['line']);
$bot->sendLog($bot->bold('[Shutdown]' . PHP_EOL) . $error_message);
}
}
}
?>
|