Форум сайта python.su
0
Все доброго дня.
Подскажите плз в чем может быть проблем. Не выводит в лог сообщения из 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()
Отредактировано apanyovin (Июль 9, 2015 14:14:26)
Офлайн
0
ответ на мой вопрос
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).
Офлайн