Permalink
Browse files

added logging support

  • Loading branch information...
1 parent 215b821 commit ee9f356aa23b8fd50560ebd44b5f851464b245e6 @emdagon committed May 25, 2012
Showing with 15 additions and 7 deletions.
  1. +9 −3 __init__.py
  2. +2 −1 objects.py
  3. +4 −3 web.py
View
@@ -17,13 +17,18 @@
# You should have received a copy of the GNU General Public License
# along with Eyestorm. If not, see <http://www.gnu.org/licenses/>.
+import logging
+
import tornado.httpserver
import tornado.ioloop
import tornado.web
from tornado.options import define, options
+
+# Dev purposes (will be removed)
from pprint import pprint
+
define('address', default='127.0.0.1', help="Server address")
define('port', default=80, help="Server port")
define('context', default="all",
@@ -72,6 +77,7 @@
#minutes
define('sesssions_lifetime', default=5)
+
_looper = tornado.ioloop.IOLoop.instance()
add_timeout = _looper.add_timeout
@@ -136,7 +142,7 @@ def start(self):
global __looper, options
if options.debug:
- print "Starting in debug mode."
+ logging.info("Starting in debug mode.")
if options.default_locale:
tornado.locale.set_default_locale(options.default_locale)
@@ -156,9 +162,9 @@ def start(self):
io_loop=_looper).start()
try:
- print "Starting %s\n" % options.app_title
+ logging.info("Starting %s", options.app_title)
_looper.start()
except KeyboardInterrupt:
- print "\nStoping %s" % options.app_title
+ logging.info("Stoping %s", options.app_title)
_looper.stop()
_looper.close()
View
@@ -18,6 +18,7 @@
# along with Eyestorm. If not, see <http://www.gnu.org/licenses/>.
from bson import ObjectId
+import logging
import tornado
import asyncmongo
@@ -46,7 +47,7 @@ class Db(object):
def __init__(self):
self._config = options.db
self._connection = asyncmongo.Client(**self._config)
- print("Mongo connection created")
+ logging.info("Mongo connection created")
def get_config(self):
return self._config
View
7 web.py
@@ -27,6 +27,7 @@
import functools
import time
from bson import ObjectId
+import logging
from tornado.web import RequestHandler, asynchronous, HTTPError, urlparse, \
urllib
@@ -143,10 +144,10 @@ def _callback(entity, error):
def sessions_cleaner():
"""Sessions expiration maintainer"""
timestamp = int(time.time())
- print "cleanning sessions... " + str(timestamp)
+ logging.debug("cleanning sessions... %i", timestamp)
def _callback(result, error):
if result and result['n'] > 0:
- print "%i sessions cleaned up!" % result['n']
+ logging.debug("%i sessions cleaned up!", result['n'])
sessions = Sessions()
sessions.remove(({'__expires': {'$lt': timestamp}}),
callback=_callback)
@@ -208,7 +209,7 @@ def _get_session_id(self):
return self.__session_id
def _set_session_id(self, value):
- print "setting cookie: %s" % value
+ logging.debug("setting cookie: %s", value)
self.set_secure_cookie(
self.application.settings.get('sessions_name'),
value,

0 comments on commit ee9f356

Please sign in to comment.