Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow logging request data in the debug log #1089

Merged
merged 6 commits into from
May 4, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
### Added
- Replaced 'generic' and 'genericmessage' strings with Telegram::GENERIC_COMMAND and Telegram::GENERIC_MESSAGE_COMMAND constants (@1int)
- Bot API 4.8 (Extra Poll and Dice features).
- `TelegramLog::$log_request_data` parameter to output the request data to the debug log.
### Changed
### Deprecated
### Removed
Expand Down
4 changes: 4 additions & 0 deletions src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,10 @@ public static function execute($action, array $data = [])
$request_params['debug'] = TelegramLog::getDebugLogTempStream();

try {
if (TelegramLog::$log_request_data) {
TelegramLog::debug('Request Data: ' . print_r($data, true));
}

$response = self::$client->post(
'/bot' . self::$telegram->getApiKey() . '/' . $action,
$request_params
Expand Down
7 changes: 7 additions & 0 deletions src/TelegramLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ class TelegramLog
*/
protected static $update_logger;

/**
* Log the request data to the debug log
*
* @var bool
*/
public static $log_request_data = false;

/**
* Temporary stream handle for debug log
*
Expand Down