Don't output deprecation error if no logging is enabled, allow more logging flexibility.

parent 80f626f2
...@@ -8,9 +8,11 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c ...@@ -8,9 +8,11 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
- [:ledger: View file changes][Unreleased] - [:ledger: View file changes][Unreleased]
### Added ### Added
### Changed ### Changed
- Logging only updates or only debug/errors is now possible.
### Deprecated ### Deprecated
### Removed ### Removed
### Fixed ### Fixed
- Don't output deprecation notices if no logging is enabled.
### Security ### Security
## [0.59.0] - 2019-07-07 ## [0.59.0] - 2019-07-07
......
...@@ -88,8 +88,8 @@ class TelegramLog ...@@ -88,8 +88,8 @@ class TelegramLog
*/ */
public static function initialize(LoggerInterface $logger = null, LoggerInterface $update_logger = null) public static function initialize(LoggerInterface $logger = null, LoggerInterface $update_logger = null)
{ {
if ($logger === null && $update_logger === null) {
// Clearly deprecated code still being executed. // Clearly deprecated code still being executed.
if ($logger === null) {
(defined('PHPUNIT_TESTSUITE') && PHPUNIT_TESTSUITE) || trigger_error('A PSR-3 compatible LoggerInterface object must be provided. Initialise with a preconfigured logger instance.', E_USER_DEPRECATED); (defined('PHPUNIT_TESTSUITE') && PHPUNIT_TESTSUITE) || trigger_error('A PSR-3 compatible LoggerInterface object must be provided. Initialise with a preconfigured logger instance.', E_USER_DEPRECATED);
$logger = new Logger('bot_log'); $logger = new Logger('bot_log');
} elseif ($logger instanceof Logger) { } elseif ($logger instanceof Logger) {
...@@ -286,11 +286,12 @@ class TelegramLog ...@@ -286,11 +286,12 @@ class TelegramLog
} elseif ($name === 'update') { } elseif ($name === 'update') {
$logger = self::$update_logger; $logger = self::$update_logger;
$name = 'info'; $name = 'info';
} else {
return;
} }
self::initialize(self::$logger, self::$update_logger); // Clearly we have no logging enabled.
if ($logger === null) {
return;
}
// Replace any placeholders from the passed context. // Replace any placeholders from the passed context.
if (count($arguments) >= 2) { if (count($arguments) >= 2) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment