Уведомления

Группа в Telegram: @pythonsu

#1 Июль 9, 2015 14:14:00

apanyovin
От:
Зарегистрирован: 2008-12-25
Сообщения: 23
Репутация: +  0  -
Профиль   Отправить e-mail  

twistd + log

Все доброго дня.

Подскажите плз в чем может быть проблем. Не выводит в лог сообщения из factory

class RedisMonitorFactory(redis.SubscriberFactory):
    maxDelay = 120
    continueTrying = True
    protocol = RedisMonitorProtocol
    task_queue = {}
    domain_settings = {}
    def __init__(self, conf):
        print "f",datetime.datetime.now()
        log.msg("+++++++++++++++++++++++++test1...")
        print "f",datetime.datetime.now()

на выходе в stdout
f 2015-07-09 14:03:37.039811
f 2015-07-09 14:03:37.039876

а в самом логе тишина

если тоже ставить в connectionMade - то все выводит.

И второй вопрос - не догнал зачем FileLogObserver.

заранее спасибо.



Отредактировано apanyovin (Июль 9, 2015 14:14:26)

Офлайн

#2 Июль 9, 2015 21:57:20

apanyovin
От:
Зарегистрирован: 2008-12-25
Сообщения: 23
Репутация: +  0  -
Профиль   Отправить e-mail  

twistd + log

ответ на мой вопрос
Your Factory is constructed (its __init__ is called) before logging is initialized; logging starts once all the server components are built and passed to the application service, so that you can print messages to the administrator interactively before the log file consumes stdio. That means that the log.msg calls don't go anywhere. If you log in other methods of Factory such as buildProtocol you will see the log messages in your log file as you expect. In other words this has everything to do with when the code is run (before or after the log file is opened) rather than where the code is declared (what class it's on).



Офлайн

Board footer

Модераторировать

Powered by DjangoBB

Lo-Fi Version