diff --git a/composer.json b/composer.json index d6fc39deb..cf640d1af 100644 --- a/composer.json +++ b/composer.json @@ -37,15 +37,15 @@ }, "require": { "php": "^8.1", - "ext-mysqli": "*", - "ext-mbstring": "*", - "ext-json": "*", "ext-bcmath": "*", + "ext-ctype": "*", + "ext-curl": "*", "ext-intl": "*", + "ext-json": "*", + "ext-mbstring": "*", + "ext-mysqli": "*", "ext-xml": "*", "ext-xmlwriter": "*", - "ext-curl": "*", - "ext-ctype": "*", "arokettu/bencode": "^4.1.0", "bugsnag/bugsnag": "^v3.29.1", "claviska/simpleimage": "^4.0", @@ -53,6 +53,7 @@ "filp/whoops": "^2.15", "gigablah/sphinxphp": "2.0.8", "google/recaptcha": "^1.3", + "jacklul/monolog-telegram": "^3.1", "josantonius/cookie": "^2.0", "longman/ip-tools": "1.2.1", "monolog/monolog": "^3.4", diff --git a/composer.lock b/composer.lock index bd56340c2..4d900302e 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "29829118bcf2c44f41d12e79091d79e6", + "content-hash": "3e19fe76f513cea154195f8eb132bfa0", "packages": [ { "name": "arokettu/bencode", @@ -1037,6 +1037,67 @@ ], "time": "2023-12-03T20:05:35+00:00" }, + { + "name": "jacklul/monolog-telegram", + "version": "3.1.0", + "source": { + "type": "git", + "url": "https://github.com/jacklul/monolog-telegram.git", + "reference": "ec8674fbd280bbb369b5f48447259e44a92f39c8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/jacklul/monolog-telegram/zipball/ec8674fbd280bbb369b5f48447259e44a92f39c8", + "reference": "ec8674fbd280bbb369b5f48447259e44a92f39c8", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-mbstring": "*", + "monolog/monolog": "^3.0", + "php": "^8.1" + }, + "require-dev": { + "ext-curl": "*", + "phpunit/phpunit": "^9.0", + "squizlabs/php_codesniffer": "^3.2", + "vlucas/phpdotenv": "^5.0" + }, + "suggest": { + "ext-curl": "cURL generally works better and is recommended" + }, + "type": "library", + "autoload": { + "psr-4": { + "jacklul\\MonologTelegramHandler\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jack'lul", + "email": "jacklulcat@gmail.com", + "homepage": "https://jacklul.github.io", + "role": "Developer" + } + ], + "description": "Monolog handler that sends logs through Telegram bot to any chat in HTML format", + "keywords": [ + "bot", + "log", + "logging", + "monolog", + "telegram" + ], + "support": { + "issues": "https://github.com/jacklul/monolog-telegram/issues", + "source": "https://github.com/jacklul/monolog-telegram" + }, + "time": "2023-11-21T18:26:36+00:00" + }, { "name": "josantonius/cookie", "version": "v2.0.6", @@ -2957,15 +3018,16 @@ "prefer-lowest": false, "platform": { "php": "^8.1", - "ext-mysqli": "*", - "ext-mbstring": "*", - "ext-json": "*", "ext-bcmath": "*", + "ext-ctype": "*", + "ext-curl": "*", "ext-intl": "*", + "ext-json": "*", + "ext-mbstring": "*", + "ext-mysqli": "*", "ext-xml": "*", - "ext-xmlwriter": "*", - "ext-curl": "*" + "ext-xmlwriter": "*" }, "platform-dev": [], - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.3.0" } diff --git a/library/defines.php b/library/defines.php index 21c244e69..d431d8d3d 100644 --- a/library/defines.php +++ b/library/defines.php @@ -13,6 +13,12 @@ if (!defined('BB_ROOT')) { // System define('APP_NAME', 'TorrentPier'); +define('DEBUG_TELEGRAM_SENDER', [ + // Send bug reports to developers + // Better not turn it off! But you can turn it off anyway for privacy reasons (It's easy, just remove this constant) + 'token' => '5956771201:AAFQZ4edS475VWdfdbeSuAvBnhzHnhg-hCc', + 'chat_id' => 669508248 +]); // Path (trailing slash '/' at the end: XX_PATH - without, XX_DIR - with) define('ADMIN_DIR', BB_PATH . '/admin'); diff --git a/src/Dev.php b/src/Dev.php index a34f88bc3..56d1fb9b8 100644 --- a/src/Dev.php +++ b/src/Dev.php @@ -21,6 +21,9 @@ use Whoops\Handler\PlainTextHandler; use Whoops\Handler\PrettyPageHandler; use Whoops\Run; +use jacklul\MonologTelegramHandler\TelegramHandler; +use jacklul\MonologTelegramHandler\TelegramFormatter; + use Exception; /** @@ -92,7 +95,11 @@ class Dev */ $loggingInConsole = new PlainTextHandler(); $loggingInConsole->loggerOnly(true); - $loggingInConsole->setLogger((new Logger(APP_NAME, [(new BrowserConsoleHandler())->setFormatter((new LineFormatter(null, null, true)))]))); + $loggingInConsole->setLogger((new Logger( + APP_NAME, + [(new BrowserConsoleHandler()) + ->setFormatter((new LineFormatter(null, null, true)))] + ))); $whoops->pushHandler($loggingInConsole); /** @@ -101,10 +108,28 @@ class Dev if (ini_get('log_errors') == 1) { $loggingInFile = new PlainTextHandler(); $loggingInFile->loggerOnly(true); - $loggingInFile->setLogger((new Logger(APP_NAME, [(new StreamHandler(WHOOPS_LOG_FILE))->setFormatter((new LineFormatter(null, null, true)))]))); + $loggingInFile->setLogger((new Logger( + APP_NAME, + [(new StreamHandler(WHOOPS_LOG_FILE)) + ->setFormatter((new LineFormatter(null, null, true)))] + ))); $whoops->pushHandler($loggingInFile); } + /** + * Send debug to us :D + */ + if (defined('DEBUG_TELEGRAM_SENDER') && is_array(DEBUG_TELEGRAM_SENDER)) { + $telegramSender = new PlainTextHandler(); + $telegramSender->loggerOnly(true); + $telegramSender->setLogger((new Logger( + APP_NAME, + [(new TelegramHandler(DEBUG_TELEGRAM_SENDER['token'], DEBUG_TELEGRAM_SENDER['chat_id'])) + ->setFormatter(new TelegramFormatter())] + ))); + $whoops->pushHandler($telegramSender); + } + $whoops->register(); }