How do I "print" something to the console in pylons?
paster serve --reload development.ini
..for debug = true
THis is what I do to load a development server for Pylons.
Howev开发者_StackOverflower, when I do:
print "hello world"
THis message doesn't print out in the console. In Django, it does.
In Pylons logging package is the method to perform logging:
import logging
log = logging.getLogger(__name__)
log.debug('hello world')
This will work as long as you have logging setup configured correctly in your development.ini. I think the code above should be sufficient without any modifications to default configuration. In case it isn't you can call log.info, log.warn, log.error or log.critical instead of log.debug for your message to pass through.
I highly recommend reading this chapter of Pylons Book.
精彩评论