Permalink
Browse files

adding logging support

  • Loading branch information...
1 parent e06bfb3 commit ee68a19b636007926c578e0fefdadfdd1d931d32 Fábio Miranda Costa committed Mar 25, 2011
Showing with 19 additions and 10 deletions.
  1. +1 −1 Makefile
  2. +4 −3 thumbor/app.py
  3. +0 −1 thumbor/detectors/face_detector/__init__.py
  4. +10 −5 thumbor/server.py
  5. +4 −0 thumbor/utils.py
View
@@ -1,5 +1,5 @@
run:
- PYTHONPATH=.:$$PYTHONPATH python thumbor/server.py
+ PYTHONPATH=.:$$PYTHONPATH python thumbor/server.py -l debug
test:
nosetests -v -s tests
View
@@ -16,7 +16,7 @@
from tornado.options import define, options, parse_config_file
from thumbor.handlers import MainHandler, HealthcheckHandler
-from thumbor.utils import real_import
+from thumbor.utils import real_import, logger
define('ENGINE', default='thumbor.engines.pil')
@@ -32,7 +32,8 @@ def __init__(self, conf_file=None):
if conf_file is None:
conf_file = self.__get_conf_file(conf_file)
-
+
+ logger.info('Config file: %s' % conf_file)
parse_config_file(conf_file)
loader = real_import(options.LOADER)
@@ -62,7 +63,7 @@ def __init__(self, conf_file=None):
super(ThumborServiceApp, self).__init__(handlers)
- def __get_conf_file(conf_file):
+ def __get_conf_file(self, conf_file):
lookup_conf_file_paths = [
os.curdir,
expanduser('~'),
@@ -32,7 +32,6 @@ def __init__(self, index, detectors):
cascade_file = options.FACE_DETECTOR_CASCADE_FILE
else:
cascade_file = join(abspath(dirname(__file__)), options.FACE_DETECTOR_CASCADE_FILE)
- print cascade_file
setattr(Detector, 'cascade', cv.Load(cascade_file))
super(Detector, self).__init__(index, detectors)
View
@@ -8,15 +8,16 @@
# http://www.opensource.org/licenses/mit-license
# Copyright (c) 2011 globo.com timehome@corp.globo.com
-import sys
import signal
import optparse
+import logging
import tornado.ioloop
from tornado.httpserver import HTTPServer
-from thumbor.app import ThumborServiceApp
from thumbor import __version__
+from thumbor.utils import logger
+from thumbor.app import ThumborServiceApp
ip = "0.0.0.0"
port = 8888
@@ -51,6 +52,7 @@ def main():
parser.add_option("-p", "--port", type="int", dest="port", default=8888, help = "The port to run this thumbor instance at [default: %default]." )
parser.add_option("-i", "--ip", dest="ip", default="0.0.0.0", help = "The host address to run this thumbor instance at [default: %default]." )
parser.add_option("-c", "--conf", dest="conf", default="", help = "The path of the configuration file to use for this thumbor instance [default: %default]." )
+ parser.add_option("-l", "--log-level", dest="log_level", default="warning", help = "The log level to be used. Possible values are: debug, info, warning, error, critical or notset. [default: %default]." )
(options, args) = parser.parse_args()
@@ -62,12 +64,15 @@ def main():
port = options.port
ip = options.ip
conf = options.conf or None
+ log_level = options.log_level
- run_app(ip, port, conf)
+ run_app(ip, port, conf, log_level)
-def run_app(ip, port, conf):
+def run_app(ip, port, conf, log_level):
global server
-
+
+ logging.basicConfig(level=getattr(logging, log_level.upper()))
+
application = ThumborServiceApp(conf)
server = HTTPServer(application)
View
@@ -8,7 +8,11 @@
# http://www.opensource.org/licenses/mit-license
# Copyright (c) 2011 globo.com timehome@corp.globo.com
+import logging
+
def real_import(name):
if '.' in name:
return reduce(getattr, name.split('.')[1:], __import__(name))
return __import__(name)
+
+logger = logging.getLogger('thumbor')

0 comments on commit ee68a19

Please sign in to comment.