Skip to content

Commit 6203da7

Browse files
committed
Use PSR-3 LoggerInterface to allow custom logging implementations.
Note that all deprecated code will be removed in the near future!
1 parent 1785d98 commit 6203da7

File tree

6 files changed

+199
-141
lines changed

6 files changed

+199
-141
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
66
## [Unreleased]
77
### Added
88
### Changed
9+
- `TelegramLog` now adheres to [PSR-3] `LoggerInterface` and allows custom logger implementations.
910
### Deprecated
11+
- Old logging that uses Monolog still works but will be removed in the near future. Use `TelegramLog::initialize($logger, $update_logger);` from now on.
1012
### Removed
1113
### Fixed
1214
### Security
@@ -280,6 +282,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
280282
[0.45.0-bc-up-download-directory]: https://github.com/php-telegram-bot/core/wiki/Breaking-backwards-compatibility#up-download-directory
281283
[0.44.0-bc-update-content-type]: https://github.com/php-telegram-bot/core/wiki/Breaking-backwards-compatibility#update-getupdatecontent
282284
[example-bot]: https://github.com/php-telegram-bot/example-bot
285+
[PSR-3]: https://www.php-fig.org/psr/psr-3
283286

284287
[Unreleased]: https://github.com/php-telegram-bot/core/compare/master...develop
285288
[0.57.0]: https://github.com/php-telegram-bot/core/compare/0.56.0...0.57.0

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"ext-curl": "*",
2929
"ext-json": "*",
3030
"ext-mbstring": "*",
31+
"psr/log": "^1.1",
3132
"monolog/monolog": "^1.24",
3233
"guzzlehttp/guzzle": "^6.3"
3334
},

composer.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Telegram.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ protected function sanitizeCommand($command)
539539
public function enableAdmin($admin_id)
540540
{
541541
if (!is_int($admin_id) || $admin_id <= 0) {
542-
TelegramLog::error('Invalid value "%s" for admin.', $admin_id);
542+
TelegramLog::error('Invalid value "' . $admin_id . '" for admin.');
543543
} elseif (!in_array($admin_id, $this->admins_list, true)) {
544544
$this->admins_list[] = $admin_id;
545545
}
@@ -632,7 +632,7 @@ public function isDbEnabled()
632632
public function addCommandsPath($path, $before = true)
633633
{
634634
if (!is_dir($path)) {
635-
TelegramLog::error('Commands path "%s" does not exist.', $path);
635+
TelegramLog::error('Commands path "' . $path . '" does not exist.');
636636
} elseif (!in_array($path, $this->commands_paths, true)) {
637637
if ($before) {
638638
array_unshift($this->commands_paths, $path);

0 commit comments

Comments
 (0)