Ejemplo n.º 1
0
def main():
    logg = logging.getLogger("signalqueue")
    # Set up color if we are in a tty and curses is installed
    
    color = False
    if curses and sys.stderr.isatty():
        try:
            curses.setupterm()
            if curses.tigetnum("colors") > 0:
                color = True
        except:
            pass
    channel = logging.StreamHandler()
    channel.setFormatter(_LogFormatter(color=color))
    logg.addHandler(channel)
    
    logg.info("YO DOGG.")
    from django.conf import settings
    
    try:
        tornado.options.parse_command_line()
        http_server = HTTPServer(Application())
        http_server.listen(settings.SQ_WORKER_PORT)
        IOLoop.instance().start()
        
    except KeyboardInterrupt:
        print 'NOOOOOOOOOOOO DOGGGGG!!!'
Ejemplo n.º 2
0
def configure_logging(logging):
    """Configure logging handler"""
    if logging.upper() not in ['DEBUG', 'INFO', 'CRITICAL',
                               'WARNING', 'ERROR']:
        return

    logger.setLevel(getattr(logging_module, logging.upper()))

    if not logger.handlers:
        channel = StreamHandler()
        channel.setFormatter(_LogFormatter(color=False))
        logger.addHandler(channel)
    logger.info("Logging handler configured with level {0}".format(logging))
Ejemplo n.º 3
0
 def setUp(self):
     self.formatter = _LogFormatter(color=False)
     # Fake color support.  We can't guarantee anything about the $TERM
     # variable when the tests are run, so just patch in some values
     # for testing.  (testing with color off fails to expose some potential
     # encoding issues from the control characters)
     self.formatter._colors = {
         logging.ERROR: u"\u0001",
         }
     self.formatter._normal = u"\u0002"
     self.formatter._color = True
     # construct a Logger directly to bypass getLogger's caching
     self.logger = logging.Logger('LogFormatterTest')
     self.logger.propagate = False
     self.tempdir = tempfile.mkdtemp()
     self.filename = os.path.join(self.tempdir, 'log.out')
     self.handler = self.make_handler(self.filename)
     self.handler.setFormatter(self.formatter)
     self.logger.addHandler(self.handler)