ACC SHELL

Path : /usr/lib/python/logging/
File Upload :
Current File : //usr/lib/python/logging/config.pyo

Ñò
rÄMc@sAdZddkZddkZddkZddkZddkZddkZddkZddkZddk	Z	yddk
Z
ddkZWnej
o
dZ
nXddklZlZdZeidjo
dZndZdaddd	„Zd
„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-2008 Vinay Sajip. All Rights Reserved.

To use, simply 'import logging' and log away!
iÿÿÿÿN(tThreadingTCPServertStreamRequestHandleriF#twin32iF'ihicCs¸ddk}|i|ƒ}t|dƒo!t|dƒo|i|ƒn|i|ƒt|ƒ}tiƒz7tiiƒti	2t
||ƒ}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ÿÿÿÿNtreadfptreadline(
tConfigParserthasattrRtreadt_create_formatterstloggingt_acquireLockt	_handlerstcleart_handlerListt_install_handlerst_install_loggerst_releaseLock(tfnametdefaultstdisable_existing_loggersRtcpt
formattersthandlers((s$/usr/lib/python2.6/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((s$/usr/lib/python2.6/logging/config.pyt_resolveZs
cCstd„|ƒS(NcSs
ti|ƒS((Rtstrip(tx((s$/usr/lib/python2.6/logging/config.pyt<lambda>is(tmap(talist((s$/usr/lib/python2.6/logging/config.pyt
_strip_spaceshscCs*|iddƒ}t|ƒphSti|dƒ}t|ƒ}h}xÛ|D]Ó}d|}|i|ƒ}d|jo|i|ddƒ}nd	}d|jo|i|ddƒ}nd	}ti}d|jo-|i|dƒ}	|	ot	|	ƒ}q	n|||ƒ}
|
||<qOW|S(
sCreate and return formattersRtkeyst,sformatter_%stformatitdatefmttclassN(
tgettlenRRR)toptionstNoneR	t	FormatterR#(RtflistRtformtsectnametoptstfstdfstct
class_nametf((s$/usr/lib/python2.6/logging/config.pyRks0



	
cCs|iddƒ}t|ƒphSti|dƒ}t|ƒ}h}g}x |D]˜}d|}|i|dƒ}|i|ƒ}d|jo|i|dƒ}	nd}	yt|ttƒƒ}Wn%t	t
fj
ot|ƒ}nX|i|dƒ}
t|
ttƒƒ}
||
Œ}d	|jo*|i|d	ƒ}|iti
|ƒnt|	ƒo|i||	ƒnt|tiiƒoQd
|jo|i|d
ƒ}
nd}
t|
ƒo|i||
fƒqãn|||<qUWx%|D]\}}|i||ƒqøW|S(sInstall and return handlersRR*R+s
handler_%sR.t	formatterttargstlevelttarget(R/R0RRR)R1tevaltvarsR	Rt	NameErrorR#tsetLevelt_levelNamestsetFormattert
issubclassRt
MemoryHandlertappendt	setTarget(RRthlistRtfixupsthandR6tklassR7tfmtR?thR@RAtt((s$/usr/lib/python2.6/logging/config.pyRˆsL






cCs|iddƒ}ti|dƒ}td„|ƒ}|idƒd}ti}|}|i|ƒ}d|jo*|i|dƒ}|iti	|ƒnx|i
D]}	|i|	ƒq©W|i|dƒ}
t|
ƒoDti|
dƒ}
t
|
ƒ}
x#|
D]}|i||ƒqWn|iiiƒ}|iƒg}
xÝ|D]Õ}d	|}|i|d
ƒ}|i|ƒ}d|jo|i|dƒ}nd}ti|ƒ}||jo‘|i|ƒ}|d
}t|ƒ}t|ƒ}|d}xB||jo4||| |jo|
i||ƒ|d}qW|i|ƒnd|jo*|i|dƒ}|iti	|ƒnx|i
D]}	|i|	ƒq•W||_d|_|i|dƒ}
t|
ƒoDti|
dƒ}
t
|
ƒ}
x#|
D]}|i||ƒqWqLqLWxa|D]Y}|ii|}||
jo"ti|_g|_
d|_q,|o
d|_q,q,WdS(sCreate and install loggerstloggersR*R+cSs
ti|ƒS((RR$(R%((s$/usr/lib/python2.6/logging/config.pyR&¹stroottlogger_rootR@Rs	logger_%stqualnamet	propagateiRiN(R/RRR'tremoveR	RTR1RERFRt
removeHandlerR0R)t
addHandlertmanagert
loggerDictR*tsorttgetintt	getLoggertindexRJRWtdisabledtNOTSETR@(RRRtllistR6RTtlogR7R@RQRLRNtexistingt
child_loggerstqnRWtloggertitprefixedtpflentnum_existing((s$/usr/lib/python2.6/logging/config.pyR³sˆ
	







"
		

	
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,tt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
connectiontrecvR0tstructtunpacktmktemptopentwritetcloseRtKeyboardInterruptt
SystemExitt	tracebackt	print_exctosRXtsocketterrorttypeR?ttypest	TupleTypetRESET_ERROR(	tselfRotconntchunktslentfileR<teterrcode((s$/usr/lib/python2.6/logging/config.pythandle"s6	"



(t__name__t
__module__t__doc__RŠ(((s$/usr/lib/python2.6/logging/config.pyRmstConfigSocketReceivercBs/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(Rƒthosttportthandler((s$/usr/lib/python2.6/logging/config.pyRRs

	
cSs‡ddk}d}xn|pf|i|iiƒggg|iƒ\}}}|o|iƒntiƒ|i}tiƒqWdS(Niÿÿÿÿi(	tselectR}tfilenoR’thandle_requestR	R
R‘R(RƒR–R‘trdtwrtex((s$/usr/lib/python2.6/logging/config.pytserve_until_stoppedZs
	N(R‹RŒRtallow_reuse_addresstDEFAULT_LOGGING_CONFIG_PORTR2RRœ(((s$/usr/lib/python2.6/logging/config.pyRŽKs
cSs=|d|d|ƒ}tiƒ|atiƒ|iƒdS(NR”R•(R	R
t	_listenerRRœ(trcvrthdlrR”tserver((s$/usr/lib/python2.6/logging/config.pytservegs


RAR?(tthreadtNotImplementedErrorRRt	threadingtThread(R”RmRŽR£((s$/usr/lib/python2.6/logging/config.pytlistens

0	cCs2to'tiƒdt_datiƒndS(sN
    Stop the listening server which was created with a call to listen().
    iN(RŸR	R
R‘R2R(((s$/usr/lib/python2.6/logging/config.pyt
stopListeningss

	(RtsysR	tlogging.handlersRR}RrR|RzR€R¤R¦tImportErrorR2tSocketServerRRRžtplatformR‚RŸRR#R)RRRR¨R©(((s$/usr/lib/python2.6/logging/config.pyt<module>s(l
#				+	[e

ACC SHELL 2018