Useful functions to log efficiently into a log.txt file and send you logs by Telegram.
Using this logger will :
- Create a
log.txtfile and append it new errors, with date and time of happening ; - Send you every info or error via Telegram.
To install, type python3 -m pip install tglog, or try with py instead of python3 if you get any error.
You need your telegram chat_id, usually a chain of integers and the token of the telegram bot you want to receive logs from.
If you don't know your telegram chat_id, just send /my_id to telegram bot @get_id_bot.
If you haven't created any telegram bot, just send /newbot to @BotFather.
How to use :
Initialization :
import tglog
my_chat_id = "12345" # Your telegram chat_id
my_bot_token = "token123" # The token of the telegram bot you want to receive logs from
# Initialize your logger :
tl = tglog.logger(my_chat_id, my_bot_token)
Use any of those functions in your code :
Useful for debugging ; Telegram bot won't send notification :
Receive message when checkpoint reached :
tl.debug("info for debugging")
Useful for logging some infos
Receive some infos :
tl.info("info to be logged")
Useful for logging errors
Receive traceback of errors :
tl.error(traceback.format_exc())
Release files for tglog 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tglog-1.0.1.tar.gz | 2.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tglog-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 5.9 kB
Release files / tglog-1.0.1.tar.gz
| Download URL | tglog-1.0.1.tar.gz |
|---|---|
| Size | 2.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0f22f25f1818a5fd835602794f3b427cbdfef1bb25d393b2d249c188631d9293
|
|
BLAKE2b-256 checksum How to use checksums |
6e860fb7bf2074f1421503b4b1a53ac8cde45194f0c161ed06592cf7bf068a83
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.6.9
|
Release files / tglog-1.0.1-py3-none-any.whl
| Download URL | tglog-1.0.1-py3-none-any.whl |
|---|---|
| Size | 3.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a0f0e0fd2dad310629aadfdf8d11a5793c693026eb2bae43e730cfaeae9a2d56
|
|
BLAKE2b-256 checksum How to use checksums |
a60ab0ff4609c100284b81944a94018fde24bbbe04cc9f79b3f8e82910c7f157
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.6.9
|