σ
ΉΧ-]c           @@  s­   d  Z  d d l m Z d d l Z d d l Z d d l Z d d l m Z d d l m	 Z	 e d    Z
 d   Z e j e
  Z e j e j d	   d
   Z d   Z d S(   sN   
flask.logging
~~~~~~~~~~~~~

:copyright: 2010 Pallets
:license: BSD-3-Clause
i    (   t   absolute_importN(   t
   LocalProxyi   (   t   requestc           C@  s   t  r t  j d St j S(   s  Find the most appropriate error stream for the application. If a request
    is active, log to ``wsgi.errors``, otherwise use ``sys.stderr``.

    If you configure your own :class:`logging.StreamHandler`, you may want to
    use this for the stream. If you are using file or dict configuration and
    can't import this directly, you can refer to it as
    ``ext://flask.logging.wsgi_errors_stream``.
    s   wsgi.errors(   R   t   environt   syst   stderr(    (    (    s,   lib/python2.7/site-packages/flask/logging.pyt   wsgi_errors_stream   s    
c         @  s\   |  j      |  } xC | rW t   f d   | j D  r> t S| j sK Pn  | j } q Wt S(   s   Check if there is a handler in the logging chain that will handle the
    given logger's :meth:`effective level <~logging.Logger.getEffectiveLevel>`.
    c         3@  s   |  ] } | j    k Vq d  S(   N(   t   level(   t   .0t   handler(   R   (    s,   lib/python2.7/site-packages/flask/logging.pys	   <genexpr>)   s    (   t   getEffectiveLevelt   anyt   handlerst   Truet	   propagatet   parentt   False(   t   loggert   current(    (   R   s,   lib/python2.7/site-packages/flask/logging.pyt   has_level_handler!   s    		s6   [%(asctime)s] %(levelname)s in %(module)s: %(message)sc         C@  s,   |  j  t j k p+ |  j p+ |  j p+ |  j S(   sͺ   Decide if a logger has direct configuration applied by checking
    its properties against the defaults.

    :param logger: The :class:`~logging.Logger` to inspect.
    (   R   t   loggingt   NOTSETR   t   filtersR   (   R   (    (    s,   lib/python2.7/site-packages/flask/logging.pyt   _has_config<   s    		c         C@  s·   t  j |  j  } x\ d D]T } t  j |  } t |  r t |  r t j d j d |  j d |   Pq q W|  j r | j r | j	 t  j
  n  t |  s³ | j t  n  | S(   s½  Get the the Flask apps's logger and configure it if needed.

    The logger name will be the same as
    :attr:`app.import_name <flask.Flask.name>`.

    When :attr:`~flask.Flask.debug` is enabled, set the logger level to
    :data:`logging.DEBUG` if it is not set.

    If there is no handler for the logger's effective level, add a
    :class:`~logging.StreamHandler` for
    :func:`~flask.logging.wsgi_errors_stream` with a basic format.
    s	   flask.appt   flasksΈ   'app.logger' is named '{name}' for this application, but configuration was found for '{old_name}', which no longer has an effect. The logging configuration should be moved to '{name}'.t   namet   old_name(   s	   flask.appR   (   R   t	   getLoggerR   R   t   warningst   warnt   formatt   debugR   t   setLevelt   DEBUGR   t
   addHandlert   default_handler(   t   appR   R   t
   old_logger(    (    s,   lib/python2.7/site-packages/flask/logging.pyt   create_loggerJ   s    	(   t   __doc__t
   __future__R    R   R   R   t   werkzeug.localR   t   globalsR   R   R   t   StreamHandlerR#   t   setFormattert	   FormatterR   R&   (    (    (    s,   lib/python2.7/site-packages/flask/logging.pyt   <module>   s   		