Skip to content

Latest commit

 

History

History
34 lines (28 loc) · 1.3 KB

01-utils.md

File metadata and controls

34 lines (28 loc) · 1.3 KB

Logging

PHP Telegram Bot library features Monolog to store logs.

Logs are divided into the following streams:

Error

Collects all the exceptions thrown by the library:

TelegramLog::initErrorLog($path . '/' . $BOT_NAME . '_error.log');

Debug

Stores requests made to the Telegram API, useful for debugging:

TelegramLog::initDebugLog($path . '/' . $BOT_NAME . '_debug.log');

Raw data

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!!

Stream and external sources

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.