Ñò ‚Ic@s5dZddkZddkZddkZddkZddkZddkZddkZddkZddk Z yddk Z ddk Z Wne j o dZ nXddklZlZdZeidjo dZndZdadd„Zd „Zd „Zd „Zd „Zed „Zd„ZdS(sž Configuration functions for the logging package for Python. The core package is based on PEP 282 and comments thereto in comp.lang.python, and influenced by Apache's log4j system. Should work under Python versions >= 1.5.2, except that source line information is not available unless 'sys._getframe()' is. Copyright (C) 2001-2004 Vinay Sajip. All Rights Reserved. To use, simply 'import logging' and log away! iÿÿÿÿN(tThreadingTCPServertStreamRequestHandleriF#twin32iF'ihcCsÉddk}|i|ƒ}t|dƒo!t|dƒo|i|ƒn|i|ƒt|ƒ}tiƒzHtiiƒttdƒo ti 2nt ||ƒ}t ||ƒWdti ƒXdS(s5 Read the logging configuration from a ConfigParser-format file. This can be called several times from an application, allowing an end user the ability to select from various pre-canned configurations (if the developer provides a mechanism to present the choices and load the chosen configuration). In versions of ConfigParser which have the readfp method [typically shipped in 2.x versions of Python], you can pass in a file-like object rather than a filename, in which case the file-like object will be read using readfp. iÿÿÿÿNtreadfptreadlinet _handlerList( t ConfigParserthasattrRtreadt_create_formatterstloggingt _acquireLockt _handlerstclearRt_install_handlerst_install_loggerst _releaseLock(tfnametdefaultsRtcpt formattersthandlers((sD/usr/lib/python2.6/site-packages/paste/script/util/logging_config.pyt fileConfig7s       cCs’ti|dƒ}|idƒ}t|ƒ}x^|D]V}|d|}yt||ƒ}Wq4tj o t|ƒt||ƒ}q4Xq4W|S(s)Resolve a dotted name to a global object.t.i(tstringtsplittpopt __import__tgetattrtAttributeError(tnametusedtfoundtn((sD/usr/lib/python2.6/site-packages/paste/script/util/logging_config.pyt_resolve[s  c Cs-|iddƒ}t|ƒphSti|dƒ}h}xê|D]â}ti|ƒ}d|}|i|ƒ}d|jo|i|ddƒ}nd }d|jo|i|ddƒ}nd }ti}d|jo-|i|dƒ} | ot | ƒ}q n|||ƒ} | ||¹stroott logger_rootR:Rs logger_%stqualnamet propagateiiN(R(RRtmaptremoveR RPR+R@RARt removeHandlerR)t addHandlerR*tmanagert loggerDictR#tgetintt getLoggerRStdisabled(RRtllistR0RPtlogR1R:RKRFRHtexistingtqnRStlogger((sD/usr/lib/python2.6/site-packages/paste/script/util/logging_config.pyR³sb     "         &cCshtp td‚ndtfd„ƒY}dtfd„ƒY}d„}tid|d|||fƒS( sW Start up a socket server on the specified port, and listen for new configurations. These will be sent as a file suitable for processing by fileConfig(). Returns a Thread object on which you can call start() to start the server, and which you can join() when appropriate. To stop the server, call stopListening(). s listen() needs threading to worktConfigStreamHandlercBseZdZd„ZRS(s¤ Handler for a logging configuration request. It expects a completely new logging configuration and uses fileConfig to install it. c Ss~ddk}y|i}|idƒ}t|ƒdjoãtid|ƒd}|ii|ƒ}x5t|ƒ|jo!||i|t|ƒƒ}qeW|idƒ}t|dƒ}|i|ƒ|i ƒyt |ƒWn,t t fj o ‚nt iƒnXti|ƒnWnYtij oJ}t|iƒtijo‚qz|id}|tjo‚qznXdS(sè Handle a request. Each request is expected to be a 4-byte length, packed using struct.pack(">L", n), followed by the config file. Uses fileConfig() to do the grunt work. iÿÿÿÿNis>Lis.initw(ttempfilet connectiontrecvR)tstructtunpacktmktemptopentwritetcloseRtKeyboardInterruptt SystemExitt tracebackt print_exctosRUtsocketterrorttypeR9ttypest TupleTypet RESET_ERROR( tselfRdtconntchunktslentfileR6teterrcode((sD/usr/lib/python2.6/site-packages/paste/script/util/logging_config.pythandles6  "    (t__name__t __module__t__doc__R(((sD/usr/lib/python2.6/site-packages/paste/script/util/logging_config.pyRbstConfigSocketReceivercBs/eZdZdZdedd„Zd„ZRS(sD A simple TCP socket-based logging config receiver. it localhostcSsCti|||f|ƒtiƒd|_tiƒd|_dS(Nii(Rt__init__R R tabortRttimeout(Rxthosttportthandler((sD/usr/lib/python2.6/site-packages/paste/script/util/logging_config.pyR…8s    cSs‡ddk}d}xn|pf|i|iiƒggg|iƒ\}}}|o|iƒntiƒ|i}tiƒqWdS(Niÿÿÿÿi( tselectRrtfilenoR‡thandle_requestR R R†R(RxR‹R†trdtwrtex((sD/usr/lib/python2.6/site-packages/paste/script/util/logging_config.pytserve_until_stopped@s   N(R€RR‚tallow_reuse_addresstDEFAULT_LOGGING_CONFIG_PORTR,R…R‘(((sD/usr/lib/python2.6/site-packages/paste/script/util/logging_config.pyRƒ1s  cSs=|d|d|ƒ}tiƒ|atiƒ|iƒdS(NR‰RŠ(R R t _listenerRR‘(trcvrthdlrR‰tserver((sD/usr/lib/python2.6/site-packages/paste/script/util/logging_config.pytserveMs   R;R9(tthreadtNotImplementedErrorRRt threadingtThread(R‰RbRƒR˜((sD/usr/lib/python2.6/site-packages/paste/script/util/logging_config.pytlistenôs  0 cCs2to'tiƒdt_datiƒndS(sN Stop the listening server which was created with a call to listen(). iN(R”R R R†R,R(((sD/usr/lib/python2.6/site-packages/paste/script/util/logging_config.pyt stopListeningYs   (R‚tsysR tlogging.handlersRRrRgRqRoRuR™R›t ImportErrorR,t SocketServerRRR“tplatformRwR”RR"R RRRRž(((sD/usr/lib/python2.6/site-packages/paste/script/util/logging_config.pyts&l    $   , A e