Skip to content

Commit 4f70bcd

Browse files
authored
Merge pull request #1009 from noplanman/remove_monolog
Remove monolog and improve updates log importer.
2 parents 45873ce + ba8c148 commit 4f70bcd

File tree

7 files changed

+197
-409
lines changed

7 files changed

+197
-409
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
66
## [Unreleased]
77
### Notes
88
- [:ledger: View file changes][Unreleased]
9+
- :exclamation: Built-in logging (Monolog) has been removed, a custom PSR-3 logger must be used now! (see #964 for more info)
910
### Added
1011
- Code snippet in `GenericmessageCommand` to keep obsolete service message system commands working.
1112
- Static boolean property `SystemCommand::$execute_deprecated` (must be assigned before handling the request) to try and execute any deprecated system command.
1213
### Changed
1314
- Small readme and code fixes / simplifications.
1415
- Upgrade PHPUnit to 8.x and PHPCS to 3.5. For tests now minimum PHP version is 7.2.
16+
- Updated updates log importer (requires PHP7+).
1517
### Deprecated
1618
### Removed
1719
- Service message system commands, which are now handled by `GenericmessageCommand`.
20+
- [:exclamation:][unreleased-bc-remove-monolog-from-core] Monolog has been removed as built-in logging engine.
1821
- Assets have been moved to a dedicated repository.
1922
### Fixed
2023
- Boolean value for Polls gets saved correctly in MySQL DB.
@@ -386,6 +389,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
386389
### Deprecated
387390
- Move `hideKeyboard` to `removeKeyboard`.
388391

392+
[unreleased-bc-remove-monolog-from-core]: https://github.com/php-telegram-bot/core/wiki/Breaking-backwards-compatibility#remove-monolog-from-core
389393
[0.58.0-sql-migration]: https://github.com/php-telegram-bot/core/tree/master/utils/db-schema-update/0.57.0-0.58.0.sql
390394
[0.58.0-bc-return-value-of-empty-entity-properties]: https://github.com/php-telegram-bot/core/wiki/Breaking-backwards-compatibility#return-value-of-empty-entity-properties
391395
[0.58.0-bc-startcommand-is-now-a-usercommand]: https://github.com/php-telegram-bot/core/wiki/Breaking-backwards-compatibility#startcommand-is-now-a-usercommand

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@
2929
"ext-json": "*",
3030
"ext-mbstring": "*",
3131
"psr/log": "^1.1",
32-
"monolog/monolog": "^1.25",
3332
"guzzlehttp/guzzle": "^6.3"
3433
},
3534
"require-dev": {
3635
"phpunit/phpunit": "^8.4",
3736
"squizlabs/php_codesniffer": "^3.4",
38-
"dms/phpunit-arraysubset-asserts": "^0.1.0"
37+
"dms/phpunit-arraysubset-asserts": "^0.1.0",
38+
"monolog/monolog": "^2.0"
3939
},
4040
"autoload": {
4141
"psr-4": {

composer.lock

Lines changed: 88 additions & 85 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

doc/01-utils.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@ The first parameter is the main logger, the second one is used for the raw updat
1515

1616
(in this example we're using [Monolog])
1717
```php
18+
use Longman\TelegramBot\TelegramLog;
1819
use Monolog\Formatter\LineFormatter;
1920
use Monolog\Handler\StreamHandler;
2021
use Monolog\Logger;
21-
use Longman\TelegramBot\TelegramLog;
2222

2323
TelegramLog::initialize(
24-
// Main logger that handles all 'error' and 'debug' logs.
24+
// Main logger that handles all 'debug' and 'error' logs.
2525
new Logger('telegram_bot', [
26-
(new StreamHandler(__DIR__ . "/logs/{$bot_username}_debug.log", Logger::DEBUG))->setFormatter(new LineFormatter(null, null, true)),
27-
(new StreamHandler(__DIR__ . "/logs/{$bot_username}_error.log", Logger::ERROR))->setFormatter(new LineFormatter(null, null, true)),
26+
(new StreamHandler($path_to_debug_log_file, Logger::DEBUG))->setFormatter(new LineFormatter(null, null, true)),
27+
(new StreamHandler($path_to_error_log_file, Logger::ERROR))->setFormatter(new LineFormatter(null, null, true)),
2828
]),
2929
// Updates logger for raw updates.
3030
new Logger('telegram_bot_updates', [
31-
(new StreamHandler(__DIR__ . "/logs/{$bot_username}_update.log", Logger::INFO))->setFormatter(new LineFormatter('%message%' . PHP_EOL)),
31+
(new StreamHandler($path_to_updates_log_file, Logger::INFO))->setFormatter(new LineFormatter('%message%' . PHP_EOL)),
3232
])
3333
);
3434
```

0 commit comments

Comments
 (0)