Skip to content

Latest commit

 

History

History
37 lines (28 loc) · 1.3 KB

01-utils.md

File metadata and controls

37 lines (28 loc) · 1.3 KB

Logging

Telegram bot library feats Monolog to store logs.

Logs are divided in those streams:

Error

Collects all the exceptions throwned by the library:

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

Debug

Stores Curl messages with the server, useful for debugging:

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

Raw data

Incoming updates (json string from webhook and getUpdates) can be logged in a text file. Set this option with the methods:

TelegramLog::initUpdateLog($path . '/' . $BOT_NAME . '_update.log');

Why I need raw log?
Telegram api changes continuously and often happen that db schema is not uptodate with new entities/features. So can happen that your table schema would not be able to store valuable new information coming from Telegram.

If you store raw data you can port all updates on the newest table schema just using this script. Remember always backup first!!

Stream and external sources

Error and Debug streams relies 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 feats a custom format for this kind of logs.