Search code examples
pythonloggingtwistedtwistd

Twisted plugin logging


I am creating a twisted plugin. There is documentation here about how to control logging for twisted apps in .tac files. However there is no similar documentation for controlling logging for plugins.

Since plugins do not create Application() objects, how can we control/customize the logging that occurs?

(a near-identical question was asked on the mailing list here, but there it doesn't seem to have gotten an answer)


Solution

  • Plugins should not configure logging. logging is normally configured directly by twistd from the command line option --logfile. Feel free to emit log messages in your plugin in the usual way as twisted.python.log.msg()

    Remember that twistd is a convenience, it's not intended to be the beginning and ending of all your twisted application container needs. If you really do need something fancier than twistd can provide, it's perfectly fine to instantiate the plugins and start the reactor yourself.