mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-07-24 12:45:05 +02:00
parent
6634291c67
commit
9bda9e246a
9 changed files with 315 additions and 504 deletions
|
@ -8,66 +8,13 @@ final class RssBridge
|
|||
|
||||
public function __construct()
|
||||
{
|
||||
Configuration::verifyInstallation();
|
||||
|
||||
$customConfig = [];
|
||||
if (file_exists(__DIR__ . '/../config.ini.php')) {
|
||||
$customConfig = parse_ini_file(__DIR__ . '/../config.ini.php', true, INI_SCANNER_TYPED);
|
||||
}
|
||||
Configuration::loadConfiguration($customConfig, getenv());
|
||||
|
||||
// Consider: ini_set('error_reporting', E_ALL & ~E_DEPRECATED);
|
||||
date_default_timezone_set(Configuration::getConfig('system', 'timezone'));
|
||||
|
||||
set_exception_handler(function (\Throwable $e) {
|
||||
self::$logger->error('Uncaught Exception', ['e' => $e]);
|
||||
http_response_code(500);
|
||||
print render(__DIR__ . '/../templates/exception.html.php', ['e' => $e]);
|
||||
exit(1);
|
||||
});
|
||||
|
||||
set_error_handler(function ($code, $message, $file, $line) {
|
||||
if ((error_reporting() & $code) === 0) {
|
||||
return false;
|
||||
}
|
||||
// In the future, uncomment this:
|
||||
//throw new \ErrorException($message, 0, $code, $file, $line);
|
||||
$text = sprintf(
|
||||
'%s at %s line %s',
|
||||
sanitize_root($message),
|
||||
sanitize_root($file),
|
||||
$line
|
||||
);
|
||||
self::$logger->warning($text);
|
||||
});
|
||||
|
||||
// There might be some fatal errors which are not caught by set_error_handler() or \Throwable.
|
||||
register_shutdown_function(function () {
|
||||
$error = error_get_last();
|
||||
if ($error) {
|
||||
$message = sprintf(
|
||||
'(shutdown) %s: %s in %s line %s',
|
||||
$error['type'],
|
||||
sanitize_root($error['message']),
|
||||
sanitize_root($error['file']),
|
||||
$error['line']
|
||||
);
|
||||
self::$logger->error($message);
|
||||
if (Debug::isEnabled()) {
|
||||
print sprintf("<pre>%s</pre>\n", e($message));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
self::$logger = new SimpleLogger('rssbridge');
|
||||
if (Debug::isEnabled()) {
|
||||
self::$logger->addHandler(new StreamHandler(Logger::DEBUG));
|
||||
} else {
|
||||
self::$logger->addHandler(new StreamHandler(Logger::INFO));
|
||||
}
|
||||
|
||||
self::$httpClient = new CurlHttpClient();
|
||||
|
||||
$cacheFactory = new CacheFactory(self::$logger);
|
||||
if (Debug::isEnabled()) {
|
||||
self::$cache = $cacheFactory->create('array');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue