This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

A python logging handler that sends logs via Telegram Bot Api

Installation

Via pip:

pip install python-telegram-handler

Usage

Register a new telegram bot and obtain a authentication token. (Instructions here https://core.telegram.org/bots#3-how-do-i-create-a-bot)

After that, you must obtain a chat_id. You can do that using included simple script. Start a new conversation with newly created bot, write something to it (it is important to initiate conversation first).

Then run a command:

telegram_handler <your token here>

If all went ok, a chat_id will be printed to stdout.

Using token and chat_id, configure log handler in your desired way. For example, using dictConfig:

{
    'version': 1,
    'handlers': {
        'telegram': {
            'class': 'telegram_handler.TelegramHandler',
            'token': 'your token',
            'chat_id': 'chat id'
        }
    },
    'loggers': {
        'my_logger': {
            'handlers': ['telegram'],
            'level': 'DEBUG'
        }
    }
}

Formatting

Currently the format of sent messages is very simple: %(asctime)s %(name)s %(levelname)s %(message)s Exception traceback will be formatted as pre-formatted fixed-width code block. (https://core.telegram.org/bots/api#markdown-style)

If you want to tweak it, configure a telegram_handler.HtmlFormatter with your desired format string. Using a dictConfig:

...
{
    'formatters': {
        'telegram': {
            'class': 'telegram_handler.HtmlFormatter',
            'fmt': '%(levelname)s %(message)s'
        }
    }
    'handlers': {
        'telegram': {
            'class': 'telegram_handler.TelegramHandler',
            'formatter': 'telegram',
            'token': 'your token',
            'chat_id': 'chat id'
        }
    }
}
...

History

1.1.3 (2016-09-22)

  • Setting escape_message field of StyledFormatter missed (@ihoru)

1.1.2 (2016-05-13)

  • Fixed setup.py requires option (changed to install_requires)

1.1.1 (2016-04-20)

  • Use HTML Formatter as default formatter for telegram handler

1.1.0 (2016-04-20)

  • Introduced HTML Formatter
  • Added log text escaping (closed #3)
  • Added requests timeout setting (closed #1)
  • Catching and logging all requests and their exceptions (closed #2)

1.0.0 (2016-04-19)

  • First PyPi release

0.1.0 (2016-04-19)

  • Initial release
Release History

Release History

1.1.3

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.1.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.1.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
python-telegram-handler-1.1.3.zip (8.9 kB) Copy SHA256 Checksum SHA256 Source Sep 22, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting