Ñò
Õ¥WJc           @   sP   d  Z  d d k Z d d k Z d d k Z d g Z d e i f d „  ƒ  YZ d S(   su   Logging related functionality

This logging Handler logs to ``environ['wsgi.errors']`` as designated
in :pep:`333`.

iÿÿÿÿNt   WSGIErrorsHandlerc           B   s5   e  Z d  Z e d „ Z d „  Z d „  Z d „  Z RS(   s®  A handler class that writes logging records to
    `environ['wsgi.errors']`.

    This code is derived from CherryPy's
    :class:`cherrypy._cplogging.WSGIErrorHandler`.

    ``cache``
        Whether the `wsgi.errors` stream is cached (instead of looked up
        via `pylons.request.environ` per every logged message). Enabling
        this option is not recommended (particularly for the use case of
        logging to `wsgi.errors` outside of a request) as the behavior
        of a cached `wsgi.errors` stream is not strictly defined. In
        particular, `mod_wsgi <http://www.modwsgi.org>`_'s `wsgi.errors`
        will raise an exception when used outside of a request.

    c         O   s,   t  i i |  | | Ž | |  _ d  |  _ d  S(   N(   t   loggingt   Handlert   __init__t   cachet   Nonet   cached_stream(   t   selfR   t   argst   kwargs(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/log.pyR   !   s    	c         C   sO   |  i  p t i i i d ƒ S|  i p  t i i i d ƒ |  _ |  i S|  i S(   s‡   Return the wsgi.errors stream

        Raises a TypeError when outside of a web request
        (pylons.request is not setup)

        s   wsgi.errors(   R   t   pylonst   requestt   environt   getR   (   R   (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/log.pyt   get_wsgierrors&   s    

c         C   s?   y |  i  ƒ  } Wn t j
 o n X| o | i ƒ  n d S(   s   Flushes the streamN(   R   t	   TypeErrort   flush(   R   t   stream(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/log.pyR   4   s    c         C   sõ   y |  i  ƒ  } Wn t j
 o nÍ X| p d Sy |  i | ƒ } d } t t d ƒ p | i | | ƒ nF y | i | | ƒ Wn- t j
 o! | i | | i d ƒ ƒ n X|  i ƒ  Wn/ t	 t
 f j
 o
 ‚  n |  i | ƒ n Xd S(   s   Emit a recordNs   %s
t   UnicodeTypes   UTF-8(   R   R   t   formatt   hasattrt   typest   writet   UnicodeErrort   encodeR   t   KeyboardInterruptt
   SystemExitt   handleError(   R   t   recordR   t   msgt   fs(    (    sc   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/log.pyt   emit>   s(    (   t   __name__t
   __module__t   __doc__t   FalseR   R   R   R   (    (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/log.pyR       s
   		
(   R"   R   R   R
   t   __all__R   R    (    (    (    sc   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/log.pyt   <module>   s
   	