BVB Source Codes

rq Show logutils.py Source code

Return Download rq: download logutils.py Source code - Download rq Source code - Type:.py
  1. # -*- coding: utf-8 -*-
  2. from __future__ import (absolute_import, division, print_function,
  3.                         unicode_literals)
  4.  
  5. import logging
  6.  
  7. from rq.utils import ColorizingStreamHandler
  8.  
  9.  
  10. def setup_loghandlers(level):
  11.     logger = logging.getLogger('rq.worker')
  12.     if not _has_effective_handler(logger):
  13.         logger.setLevel(level)
  14.         # This statement doesn't set level properly in Python-2.6
  15.         # Following is an additional check to see if level has been set to
  16.         # appropriate(int) value
  17.         if logger.getEffectiveLevel() == level:
  18.             # Python-2.6. Set again by using logging.INFO etc.
  19.             level_int = getattr(logging, level)
  20.             logger.setLevel(level_int)
  21.         formatter = logging.Formatter(fmt='%(asctime)s %(message)s',
  22.                                       datefmt='%H:%M:%S')
  23.         handler = ColorizingStreamHandler()
  24.         handler.setFormatter(formatter)
  25.         logger.addHandler(handler)
  26.  
  27.  
  28. def _has_effective_handler(logger):
  29.     """
  30.    Checks if a logger has a handler that will catch its messages in its logger hierarchy.
  31.    :param `logging.Logger` logger: The logger to be checked.
  32.    :return: True if a handler is found for the logger, False otherwise.
  33.    :rtype: bool
  34.    """
  35.     while True:
  36.         if logger.handlers:
  37.             return True
  38.         if not logger.parent:
  39.             return False
  40.         logger = logger.parent
  41.  
downloadlogutils.py Source code - Download rq Source code
Related Source Codes/Software:
amazon-dsstne - Deep Scalable Sparse Tensor Network Engine (DSSTNE... 2017-01-08
webpack-demos - a collection of simple demos of Webpack 2017-01-08
Squire - HTML5 rich text editor. Try the demo integration a... 2017-01-08
thor - Thor is a toolkit for building powerful command-li... 2017-01-08
glide - Package Management for Golang h... 2017-01-08
emmet-vim - emmet for vim: http://emmet.io/ ... 2017-01-08
prose - A Content Editor for GitHub. ht... 2017-01-08
sshrc - ring your .bashrc, .vimrc, etc. with you when you ... 2017-01-08
typed.js - A jQuery typing animation script. ... 2017-01-08
find - High-precision indoor positioning framework for mo... 2017-01-08
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top