Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No handlers could be found for logger "pytg.sender" #33

Closed
natalylopez opened this issue Jul 7, 2015 · 3 comments
Closed

No handlers could be found for logger "pytg.sender" #33

natalylopez opened this issue Jul 7, 2015 · 3 comments

Comments

@natalylopez
Copy link

Trying on the Raspberry pi B and Raspberry pi 2 - No Work :(

nataly@nsa-rp1 ~ $ cat bot.py
from pytg import Telegram
tg = Telegram(
 telegram="/home/nataly/tg/bin/telegram-cli",
 pubkey_file="/home/nataly/tg/server.pub")
receiver = tg.receiver
sender = tg.sender
nataly@nsa-rp1 ~ $ python bot.py
No handlers could be found for logger "pytg.sender"
@natalylopez natalylopez changed the title Trying in Raspberry pi B and Raspberry pi 2 - No Work :( Trying on Raspberry pi B and Raspberry pi 2 - No Work :( Jul 7, 2015
@natalylopez natalylopez changed the title Trying on Raspberry pi B and Raspberry pi 2 - No Work :( Trying on the Raspberry pi B and Raspberry pi 2 - No Work :( Jul 7, 2015
@luckydonald
Copy link
Owner

You are probably using python 2.x?

Until I fixed it, add this two lines to the beginning of your code:

import logging
logging.basicConfig()

Loggers in Python versions below 3 fail, if there is no handler defined. The lines above does that for you.
I'll add a Dummy listener to pytg to avoid that error in future.

@luckydonald luckydonald changed the title Trying on the Raspberry pi B and Raspberry pi 2 - No Work :( No handlers could be found for logger "pytg.sender" Jul 23, 2015
@luckydonald luckydonald added this to the Pytg 1.0 milestone Sep 7, 2015
@luckydonald luckydonald reopened this Dec 1, 2015
@luckydonald
Copy link
Owner

Why did I reopen this? because it is untested?

@luckydonald
Copy link
Owner

luckydonald commented Jul 21, 2016

Requests does it like this:

# Set default logging handler to avoid "No handler found" warnings.
import logging
try:  # Python 2.7+
    from logging import NullHandler
except ImportError:
    class NullHandler(logging.Handler):
        def emit(self, record):
            pass

logging.getLogger(__name__).addHandler(NullHandler())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants