PHP Telegram Bot library features Monolog to store logs.
Logs are divided into the following streams:
Collects all the exceptions thrown by the library:
TelegramLog::initErrorLog($path . '/' . $BOT_NAME . '_error.log');
Stores requests made to the Telegram API, useful for debugging:
TelegramLog::initDebugLog($path . '/' . $BOT_NAME . '_debug.log');
Incoming updates (JSON string from Webhook and getUpdates) get logged in a text file:
TelegramLog::initUpdateLog($path . '/' . $BOT_NAME . '_update.log');
Why do I need to log the raw updates? Telegram API changes continuously and it often happens that the database schema is not up to date with new entities/features. So it can happen that your table schema doesn't allow storing new valuable information coming from Telegram.
If you store the raw data you can import all updates on the newest table schema by simply using this script. Remember to always backup first!!
Error and Debug streams rely on the bot_log
instance that can be provided from an external source:
TelegramLog::initialize($monolog);
Raw data relies on the bot_update_log
instance that uses a custom format.