Your IP : 216.73.216.108
�
��f�c@sOdZddlZddlZddlZddlZddlZddlZddlZddlZddl m
Z
ddlmZm
Z
mZddlZyddlZWnek
r�dZYnXdZdZdZdZd Zd Zd)ZGdd
�d
ej�ZGdd�de�ZGdd�de�ZGdd�dej�ZGdd�dej�Z Gdd�de �Z!Gdd�dej�Z"Gdd�dej�Z#Gdd�dej�Z$Gdd�dej�Z%Gd d!�d!ej�Z&Gd"d#�d#e&�Z'Gd$d%�d%ej�Z(erKGd&d'�d'e)�Z*ndS(*u�
Additional handlers for the logging package for Python. The core package is
based on PEP 282 and comments thereto in comp.lang.python.
Copyright (C) 2001-2013 Vinay Sajip. All Rights Reserved.
To use, simply 'import logging.handlers' and log away!
iN(uBOM_UTF8(uST_DEVuST_INOuST_MTIMEi<#i=#i>#i?#iii<cBsP|EeZdZdZd
ddd�Zdd�Zdd�Zdd �Z d
S(uBaseRotatingHandleru�
Base class for handlers that rotate log files at a certain point.
Not meant to be instantiated directly. Instead, use RotatingFileHandler
or TimedRotatingFileHandler.
cCsDtjj|||||�||_||_d|_d|_dS(uA
Use the specified filename for streamed logging
N(ulogginguFileHandleru__init__umodeuencodinguNoneunamerurotator(uselfufilenameumodeuencodingudelay((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyu__init__6s
uBaseRotatingHandler.__init__cCsiy3|j|�r|j�ntjj||�Wn/ttfk
rP�Yn|j|�YnXdS(u�
Emit a record.
Output the record to the file, catering for rollover as described
in doRollover().
N(ushouldRolloveru
doRolloverulogginguFileHandleruemituKeyboardInterruptu
SystemExituhandleError(uselfurecord((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyuemit@s
uBaseRotatingHandler.emitcCs+t|j�s|}n|j|�}|S(u�
Modify the filename of a log file when rotating.
This is provided so that a custom filename can be provided.
The default implementation calls the 'namer' attribute of the
handler, if it's callable, passing the default name to
it. If the attribute isn't callable (the default is None), the name
is returned unchanged.
:param default_name: The default name for the log file.
(ucallableunamer(uselfudefault_nameuresult((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyurotation_filenamePs
u%BaseRotatingHandler.rotation_filenamecCsKt|j�s7tjj|�rGtj||�qGn|j||�dS(uL
When rotating, rotate the current log.
The default implementation calls the 'rotator' attribute of the
handler, if it's callable, passing the source and dest arguments to
it. If the attribute isn't callable (the default is None), the source
is simply renamed to the destination.
:param source: The source filename. This is normally the base
filename, e.g. 'test.log'
:param dest: The destination filename. This is normally
what the source is rotated to, e.g. 'test.log.1'.
N(ucallableurotatoruosupathuexistsurename(uselfusourceudest((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyurotatecsuBaseRotatingHandler.rotateNF(
u__name__u
__module__u__qualname__u__doc__uNoneuFalseu__init__uemiturotation_filenameurotate(u
__locals__((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyuBaseRotatingHandler0s
uBaseRotatingHandlercBsM|EeZdZdZdddd
ddd�Zdd�Zdd �Zd
S(uRotatingFileHandleru�
Handler for logging to a set of files, which switches from one file
to the next when the current file reaches a certain size.
uaicCsD|dkrd}ntj|||||�||_||_dS(u�
Open the specified file and use it as the stream for logging.
By default, the file grows indefinitely. You can specify particular
values of maxBytes and backupCount to allow the file to rollover at
a predetermined size.
Rollover occurs whenever the current log file is nearly maxBytes in
length. If backupCount is >= 1, the system will successively create
new files with the same pathname as the base file, but with extensions
".1", ".2" etc. appended to it. For example, with a backupCount of 5
and a base file name of "app.log", you would get "app.log",
"app.log.1", "app.log.2", ... through to "app.log.5". The file being
written to is always "app.log" - when it gets filled up, it is closed
and renamed to "app.log.1", and if files "app.log.1", "app.log.2" etc.
exist, then they are renamed to "app.log.2", "app.log.3" etc.
respectively.
If maxBytes is zero, rollover never occurs.
iuaN(uBaseRotatingHandleru__init__umaxBytesubackupCount(uselfufilenameumodeumaxBytesubackupCountuencodingudelay((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyu__init__}s
uRotatingFileHandler.__init__cCsE|jr"|jj�d|_n|jdkr&x�t|jddd�D]�}|jd|j|f�}|jd|j|df�}tjj |�rKtjj |�r�tj
|�ntj||�qKqKW|j|jd�}tjj |�rtj
|�n|j|j|�n|j
sA|j�|_ndS(u<
Do a rollover, as described in __init__().
iiu%s.%du.1Ni����(ustreamucloseuNoneubackupCounturangeurotation_filenameubaseFilenameuosupathuexistsuremoveurenameurotateudelayu_open(uselfuiusfnudfn((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyu
doRollover�s$
uRotatingFileHandler.doRollovercCs�|jdkr!|j�|_n|jdkrd|j|�}|jjdd�|jj�t|�|jkrdSndS(u�
Determine if rollover should occur.
Basically, see if the supplied record would cause the file to exceed
the size limit we have.
iu%s
iiN(ustreamuNoneu_openumaxBytesuformatuseekutellulen(uselfurecordumsg((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyushouldRollover�s"u"RotatingFileHandler.shouldRolloverNF( u__name__u
__module__u__qualname__u__doc__uNoneuFalseu__init__u
doRolloverushouldRollover(u
__locals__((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyuRotatingFileHandlerxs uRotatingFileHandlercBsh|EeZdZdZdddddddd�Zdd�Zd d
�Zdd�Z d
d�Z
dS(uTimedRotatingFileHandleru�
Handler for logging to a file, rotating the log file at certain timed
intervals.
If backupCount is > 0, when rollover is done, no more than backupCount
files are kept - the oldest ones are deleted.
uhiic Cs8tj||d||�|j�|_||_||_|jdkrgd|_d|_d|_nV|jdkr�d|_d|_d |_n)|jd
kr�d|_d|_d|_n�|jd
ks�|jdkr�d|_d|_d|_n�|jj d�r�d|_t
|j�dkrCtd|j��n|jddksi|jddkrtd|j��nt|jd�|_
d|_d|_ntd|j��tj|jtj�|_|j||_tjj|�rtj|�t}nttj��}|j|�|_dS( NuauSiu%Y-%m-%d_%H-%M-%Su-^\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2}(\.\w+)?$uMi<u%Y-%m-%d_%H-%Mu'^\d{4}-\d{2}-\d{2}_\d{2}-\d{2}(\.\w+)?$uHu%Y-%m-%d_%Hu!^\d{4}-\d{2}-\d{2}_\d{2}(\.\w+)?$uDuMIDNIGHTiu%Y-%m-%du^\d{4}-\d{2}-\d{2}(\.\w+)?$uWiiuHYou must specify a day for weekly rollover from 0 to 6 (0 is Monday): %su0u6u-Invalid day specified for weekly rollover: %su'Invalid rollover interval specified: %siii�Qii�Qi�: (uBaseRotatingHandleru__init__uupperuwhenubackupCountuutcuintervalusuffixuextMatchu
startswithulenu
ValueErroruintu dayOfWeekureucompileuASCIIuosupathuexistsustatuST_MTIMEutimeucomputeRolloveru
rolloverAt( uselfufilenameuwhenuintervalubackupCountuencodingudelayuutcut((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyu__init__�sH
& u!TimedRotatingFileHandler.__init__cCsq||j}|jdks.|jjd�rm|jrItj|�}ntj|�}|d}|d}|d}t|d|d|}||}|jjd�rm|d}||jkrj||jkr�|j|} nd||jd} || d}
|js^|d
}tj|
�d}||kr^|sHd}
nd
}
|
|
7}
q^n|
}qjqmn|S(uI
Work out the rollover time based on the specified time.
uMIDNIGHTuWiiii<iiiiii�Qi����i����i��( uintervaluwhenu
startswithuutcutimeugmtimeu localtimeu _MIDNIGHTu dayOfWeek(uselfucurrentTimeuresultutucurrentHouru
currentMinuteu
currentSecondurudayu
daysToWaitu
newRolloverAtudstNowu
dstAtRolloveruaddend((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyucomputeRollovers8
!
u(TimedRotatingFileHandler.computeRollovercCs)ttj��}||jkr%dSdS(u�
Determine if rollover should occur.
record is not used, as we are just comparing times, but it is needed so
the method signatures are the same
ii(uintutimeu
rolloverAt(uselfurecordut((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyushouldRollover=su'TimedRotatingFileHandler.shouldRolloverc Cs�tjj|j�\}}tj|�}g}|d}t|�}xh|D]`}|d|�|krM||d�}|jj|�r�|jtjj ||��q�qMqMW|j
�t|�|jkr�g}n|dt|�|j�}|S(u�
Determine the files to delete when rolling over.
More specific than the earlier method, which just used glob.glob().
u.N(uosupathusplitubaseFilenameulistdirulenuextMatchumatchuappendujoinusortubackupCount( uselfudirNameubaseNameu fileNamesuresultuprefixuplenufileNameusuffix((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyugetFilesToDeleteIs
&
u)TimedRotatingFileHandler.getFilesToDeletecCs|jr"|jj�d|_nttj��}tj|�d}|j|j}|jrrtj |�}nPtj|�}|d }||kr�|r�d}nd
}tj||�}n|j
|jdtj|j
|��}tjj|�r
tj|�n|j|j|�|jdkrVx$|j�D]}tj|�q<Wn|jsq|j�|_n|j|�} x| |kr�| |j} q�W|jdks�|jjd�r|jrtj| �d}
||
kr|s�d}nd}| |7} qn| |_dS(
ux
do a rollover; in this case, a date/time stamp is appended to the filename
when the rollover happens. However, you want the file to be named for the
start of the interval, not the current time. If there is a backup count,
then we have to get a list of matching filenames, sort them and remove
the one with the oldest suffix.
iiu.iuMIDNIGHTuWNi����i����i��i����i��(ustreamucloseuNoneuintutimeu localtimeu
rolloverAtuintervaluutcugmtimeurotation_filenameubaseFilenameustrftimeusuffixuosupathuexistsuremoveurotateubackupCountugetFilesToDeleteudelayu_openucomputeRolloveruwhenu
startswith(uselfucurrentTimeudstNowutu timeTupleudstThenuaddendudfnusu
newRolloverAtu
dstAtRollover((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyu
doRollover`sH
+ u#TimedRotatingFileHandler.doRolloverNF(u__name__u
__module__u__qualname__u__doc__uNoneuFalseu__init__ucomputeRolloverushouldRolloverugetFilesToDeleteu
doRollover(u
__locals__((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyuTimedRotatingFileHandler�s5<uTimedRotatingFileHandlercBsG|EeZdZdZdd d
dd�Zdd�Zdd�Zd S(uWatchedFileHandleru�
A handler for logging to a file, which watches the file
to see if it has changed while in use. This can happen because of
usage of programs such as newsyslog and logrotate which perform
log file rotation. This handler, intended for use under Unix,
watches the file to see if it has changed since the last emit.
(A file has changed if its device or inode have changed.)
If it has changed, the old file stream is closed, and the file
opened to get a new stream.
This handler is not appropriate for use under Windows, because
under Windows open files cannot be moved or renamed - logging
opens the files with exclusive locks - and so there is no need
for such a handler. Furthermore, ST_INO is not supported under
Windows; stat always returns zero for this value.
This handler is based on a suggestion and patch by Chad J.
Schroeder.
uacCs<tjj|||||�d\|_|_|j�dS(Nii����i����(i����i����(ulogginguFileHandleru__init__udevuinou_statstream(uselfufilenameumodeuencodingudelay((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyu__init__�suWatchedFileHandler.__init__cCsC|jr?tj|jj��}|t|t|_|_ndS(N(ustreamuosufstatufilenouST_DEVuST_INOudevuino(uselfusres((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyu_statstream�s uWatchedFileHandler._statstreamcCs�ytj|j�}WnCtk
r[}z#|jtjkrFd}n�WYdd}~XnX|s�|t|jks�|t |j
kr�|jdk r�|jj�|jj
�|j�|_|j�q�ntjj||�dS(u�
Emit a record.
First check if the underlying file has changed, and if it
has, close the old stream and reopen the file to get the
current stream.
N(uosustatubaseFilenameuOSErroruerrnouENOENTuNoneuST_DEVudevuST_INOuinoustreamuflushucloseu_openu_statstreamulogginguFileHandleruemit(uselfurecordusresuerr((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyuemit�s -
uWatchedFileHandler.emitNF( u__name__u
__module__u__qualname__u__doc__uNoneuFalseu__init__u_statstreamuemit(u
__locals__((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyuWatchedFileHandler�suWatchedFileHandlercBs}|EeZdZdZdd�Zddd�Zdd�Zd d
�Zdd�Zd
d�Z dd�Z
dd�ZdS(u
SocketHandleru
A handler class which writes logging records, in pickle format, to
a streaming socket. The socket is kept open across logging calls.
If the peer resets it, an attempt is made to reconnect on the next call.
The pickle which is sent is that of the LogRecord's attribute dictionary
(__dict__), so that the receiver does not need to have the logging module
installed in order to process the logging event.
To unpickle the record at the receiving end into a LogRecord, use the
makeLogRecord function.
cCs\tjj|�||_||_d|_d|_d|_ d|_
d|_d|_dS(u
Initializes the handler with a specific host address and port.
When the attribute *closeOnError* is set to True - if a socket error
occurs, the socket is silently closed and then reopened on the next
logging call.
g�?g>@g@NF(
ulogginguHandleru__init__uhostuportuNoneusockuFalseucloseOnErroru retryTimeu
retryStarturetryMaxuretryFactor(uselfuhostuport((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyu__init__�s uSocketHandler.__init__icCs�tjtjtj�}t|d�r7|j|�ny!|j|j|jf�|SWn"tjk
r||j ��YnXdS(ur
A factory method which allows subclasses to define the precise
type of socket they want.
u
settimeoutN(
usocketuAF_INETuSOCK_STREAMuhasattru
settimeoutuconnectuhostuportuerroruclose(uselfutimeoutus((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyu
makeSocket�s
uSocketHandler.makeSocketcCs�tj�}|jdkr$d}n||jk}|r�y|j�|_d|_Wq�tjk
r�|jdkr�|j|_ n4|j |j
|_ |j |jkr�|j|_ n||j |_Yq�XndS(u�
Try to create a socket, using an exponential backoff with
a max retry time. Thanks to Robert Olson for the original patch
(SF #815911) which has been slightly refactored.
NT(utimeu retryTimeuNoneuTrueu
makeSocketusockusocketuerroru
retryStarturetryPerioduretryFactoruretryMax(uselfunowuattempt((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyucreateSockets
uSocketHandler.createSocketcCs�|jdkr|j�n|jr�y~t|jd�rM|jj|�nUd}t|�}x@|dkr�|jj||d��}||}||}qbWWq�tjk
r�|jj �d|_Yq�XndS(u�
Send a pickled string to the socket.
This function allows for partial sends which can happen when the
network is busy.
usendalliN(
usockuNoneucreateSocketuhasattrusendallulenusendusocketuerroruclose(uselfusu sentsofaruleftusent((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyusends
uSocketHandler.sendcCs�|j}|r!|j|�}nt|j�}|j�|d<d|d<d|d<tj|d�}tj dt
|��}||S(u�
Pickles the record in binary format with a length prefix, and
returns it ready for transmission across the socket.
umsguargsuexc_infoiu>LN(uexc_infouformatudictu__dict__u
getMessageuNoneupickleudumpsustructupackulen(uselfurecordueiudummyudususlen((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyu
makePickle8s
uSocketHandler.makePicklecCsB|jr+|jr+|jj�d|_ntjj||�dS(u�
Handle an error during logging.
An error has occurred during logging. Most likely cause -
connection lost. Close the socket so that we can retry on the
next event.
N(ucloseOnErrorusockucloseuNoneulogginguHandleruhandleError(uselfurecord((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyuhandleErrorLs
uSocketHandler.handleErrorcCsVy |j|�}|j|�Wn/ttfk
r=�Yn|j|�YnXdS(u
Emit a record.
Pickles the record and writes it to the socket in binary format.
If there is an error with the socket, silently drop the packet.
If there was a problem with the socket, re-establishes the
socket.
N(u
makePickleusenduKeyboardInterruptu
SystemExituhandleError(uselfurecordus((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyuemitZs uSocketHandler.emitc
CsR|j�z6|jr/|jj�d|_ntjj|�Wd|j�XdS(u$
Closes the socket.
N(uacquireusockucloseuNoneulogginguHandlerurelease(uself((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyucloseks
uSocketHandler.closeN(u__name__u
__module__u__qualname__u__doc__u__init__u
makeSocketucreateSocketusendu
makePickleuhandleErroruemituclose(u
__locals__((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyu
SocketHandler�su
SocketHandlercBs>|EeZdZdZdd�Zdd�Zdd�ZdS( uDatagramHandleru�
A handler class which writes logging records, in pickle format, to
a datagram socket. The pickle which is sent is that of the LogRecord's
attribute dictionary (__dict__), so that the receiver does not need to
have the logging module installed in order to process the logging event.
To unpickle the record at the receiving end into a LogRecord, use the
makeLogRecord function.
cCs tj|||�d|_dS(uP
Initializes the handler with a specific host address and port.
NF(u
SocketHandleru__init__uFalseucloseOnError(uselfuhostuport((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyu__init__�suDatagramHandler.__init__cCstjtjtj�}|S(uu
The factory method of SocketHandler is here overridden to create
a UDP socket (SOCK_DGRAM).
(usocketuAF_INETu
SOCK_DGRAM(uselfus((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyu
makeSocket�suDatagramHandler.makeSocketcCs?|jdkr|j�n|jj||j|jf�dS(u�
Send a pickled string to a socket.
This function no longer allows for partial sends which can happen
when the network is busy - UDP does not guarantee delivery and
can deliver packets out of sequence.
N(usockuNoneucreateSocketusendtouhostuport(uselfus((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyusend�s
uDatagramHandler.sendN(u__name__u
__module__u__qualname__u__doc__u__init__u
makeSocketusend(u
__locals__((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyuDatagramHandlerxs
uDatagramHandlercBsA|EeZdZdZdZdZdZdZdZdZ dZ
d ZdZdZ
dZdZdZdZdZd Zd
ZdZdZd
ZdZdZdZdZdZdZdZdZied6ed6ed6ed6ed6ed6ed6e
d6e d6ed6ed 6ed!6Z ied"6ed#6ed$6ed%6ed&6ed'6ed(6ed)6ed*6ed+6ed,6e
d-6ed.6ed/6ed06ed16ed26ed36ed46ed56ed66Z!idd76dd86d!d96dd:6dd;6Z"d<e#fe
dJd=d>�Z%d?d@�Z&dAdB�Z'dCdD�Z(dEdF�Z)dGZ*dKZ,dHdI�Z-dJS(Lu
SysLogHandleru
A handler class which sends formatted logging records to a syslog
server. Based on Sam Rushing's syslog module:
http://www.nightmare.com/squirl/python-ext/misc/syslog.py
Contributed by Nicolas Untz (after which minor refactoring changes
have been made).
iiiiiiiiii i
iiiiiiiiiualertucritucriticaludebuguemerguerruerroruinfounoticeupanicuwarnuwarninguauthuauthprivucronudaemonuftpukernulprumailunewsusecurityusysloguuseruuucpulocal0ulocal1ulocal2ulocal3ulocal4ulocal5ulocal6ulocal7uDEBUGuINFOuWARNINGuERRORuCRITICALu localhostcCs�tjj|�||_||_||_t|t�rSd|_ |j
|�ndd|_ |dkrtt
j}nt
j
t
j|�|_
|t
jkr�|j
j|�n||_d|_dS(u�
Initialize a handler.
If address is specified as a string, a UNIX socket is used. To log to a
local syslogd, "SysLogHandler(address="/dev/log")" can be used.
If facility is not specified, LOG_USER is used.
NTF(ulogginguHandleru__init__uaddressufacilityusocktypeu
isinstanceustruTrueu
unixsocketu_connect_unixsocketuFalseuNoneusocketu
SOCK_DGRAMuAF_INETuSOCK_STREAMuconnectu formatter(uselfuaddressufacilityusocktype((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyu__init__s uSysLogHandler.__init__cCs�|j}|dkr!tj}ntjtj|�|_y|jj|�||_Wn�tjk
r�|jj�|jdk r��ntj}tjtj|�|_y|jj|�||_Wn%tjk
r�|jj��YnXYnXdS(N( usocktypeuNoneusocketu
SOCK_DGRAMuAF_UNIXuconnectuerrorucloseuSOCK_STREAM(uselfuaddressuuse_socktype((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyu_connect_unixsocket!s&
u!SysLogHandler._connect_unixsocketcCsJt|t�r|j|}nt|t�r>|j|}n|d>|BS(u�
Encode the facility and priority. You can pass in strings or
integers - if strings are passed, the facility_names and
priority_names mapping dictionaries are used to convert them to
integers.
i(u
isinstanceustrufacility_namesupriority_names(uselfufacilityupriority((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyuencodePriority9s
uSysLogHandler.encodePriorityc
Cs=|j�z!|jj�tjj|�Wd|j�XdS(u$
Closes the socket.
N(uacquireusocketucloseulogginguHandlerurelease(uself((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyucloseFs
uSysLogHandler.closecCs|jj|d�S(uK
Map a logging level name to a key in the priority_names map.
This is useful in two scenarios: when custom levels are being
used, and in the case where you can't do a straightforward
mapping by lowercasing the logging level name because of locale-
specific issues (see SF #1524081).
uwarning(upriority_mapuget(uselfu levelName((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyumapPriorityQsuSysLogHandler.mapPriorityucCse|j|�}|jr(|j|}n|jr>|d7}nd|j|j|j|j��}|jd�}|jd�}||}y�|jr�y|j j
|�Wq.t jk
r�|j j�|j
|j�|j j
|�Yq.Xn;|jt jkr|j j||j�n|j j|�Wn/ttfk
rL�Yn|j|�YnXdS(u�
Emit a record.
The record is formatted, and then sent to the syslog server. If
exception information is present, it is NOT sent to the server.
uu<%d>uutf-8N(uformatuidentu
append_nuluencodePriorityufacilityumapPriorityu levelnameuencodeu
unixsocketusocketusenduerrorucloseu_connect_unixsocketuaddressusocktypeu
SOCK_DGRAMusendtousendalluKeyboardInterruptu
SystemExituhandleError(uselfurecordumsguprio((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyuemit^s2
uSysLogHandler.emitNT(.u__name__u
__module__u__qualname__u__doc__u LOG_EMERGu LOG_ALERTuLOG_CRITuLOG_ERRuLOG_WARNINGu
LOG_NOTICEuLOG_INFOu LOG_DEBUGuLOG_KERNuLOG_USERuLOG_MAILu
LOG_DAEMONuLOG_AUTHu
LOG_SYSLOGuLOG_LPRuLOG_NEWSuLOG_UUCPuLOG_CRONuLOG_AUTHPRIVuLOG_FTPu
LOG_LOCAL0u
LOG_LOCAL1u
LOG_LOCAL2u
LOG_LOCAL3u
LOG_LOCAL4u
LOG_LOCAL5u
LOG_LOCAL6u
LOG_LOCAL7upriority_namesufacility_namesupriority_mapuSYSLOG_UDP_PORTuNoneu__init__u_connect_unixsocketuencodePriorityucloseumapPriorityuidentuTrueu
append_nuluemit(u
__locals__((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyu
SysLogHandler�s�
u
SysLogHandlercBsG|EeZdZdZd d ddd�Zdd�Zdd�Zd S(
uSMTPHandleruK
A handler class which sends an SMTP email for each logging event.
g@cCs�tjj|�t|t�r4|\|_|_n|d|_|_t|t�rk|\|_|_ n d|_||_
t|t�r�|g}n||_||_
||_||_dS(ux
Initialize the handler.
Initialize the instance with the from and to addresses and subject
line of the email. To specify a non-standard SMTP port, use the
(host, port) tuple format for the mailhost argument. To specify
authentication credentials, supply a (username, password) tuple
for the credentials argument. To specify the use of a secure
protocol (TLS), pass in a tuple for the secure argument. This will
only be used when authentication credentials are supplied. The tuple
will be either an empty tuple, or a single-value tuple with the name
of a keyfile, or a 2-value tuple with the names of the keyfile and
certificate file. (This tuple is passed to the `starttls` method).
A timeout in seconds can be specified for the SMTP connection (the
default is one second).
N(ulogginguHandleru__init__u
isinstanceutupleumailhostumailportuNoneuusernameupasswordufromaddrustrutoaddrsusubjectusecureutimeout(uselfumailhostufromaddrutoaddrsusubjectucredentialsusecureutimeout((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyu__init__�s uSMTPHandler.__init__cCs|jS(u�
Determine the subject for the email.
If you want to specify a subject line which is record-dependent,
override this method.
(usubject(uselfurecord((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyu
getSubject�suSMTPHandler.getSubjectcCsMyddl}ddlm}|j}|s:|j}n|j|j|d|j�}|j|�}d|j dj
|j�|j|�|�|f}|j
r�|jdk r�|j�|j|j�|j�n|j|j
|j�n|j|j |j|�|j�Wn/ttfk
r4�Yn|j|�YnXdS(ud
Emit a record.
Format the record and send it to the specified addressees.
iN(u
formatdateutimeoutu-From: %s
To: %s
Subject: %s
Date: %s
%su,(usmtplibuemail.utilsu
formatdateumailportu SMTP_PORTuSMTPumailhostutimeoutuformatufromaddrujoinutoaddrsu
getSubjectuusernameusecureuNoneuehloustarttlsuloginupasswordusendmailuquituKeyboardInterruptu
SystemExituhandleError(uselfurecordusmtplibu
formatdateuportusmtpumsg((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyuemit�s2
uSMTPHandler.emitN(u__name__u
__module__u__qualname__u__doc__uNoneu__init__u
getSubjectuemit(u
__locals__((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyuSMTPHandler�s" uSMTPHandlercBsh|EeZdZdZdddd�Zdd�Zdd�Zd d
�Zdd�Z d
d�Z
dS(uNTEventLogHandleru�
A handler class which sends events to the NT Event Log. Adds a
registry entry for the specified application name. If no dllname is
provided, win32service.pyd (which contains some basic message
placeholders) is used. Note that use of these placeholders will make
your event logs big, as the entire message source is held in the log.
If you want slimmer logs, you have to pass in the name of your own DLL
which contains the message definitions you want to use in the event log.
uApplicationcCs8tjj|�y�ddl}ddl}||_||_|s�tjj |jj
�}tjj |d�}tjj|dd�}n||_||_
|jj|||�|j|_i|jtj6|jtj6|jtj6|jtj6|jtj6|_Wn%tk
r3td�d|_YnXdS(Niuwin32service.pyduWThe Python Win32 extensions for NT (service, event logging) appear not to be available.(ulogginguHandleru__init__uwin32evtlogutiluwin32evtloguappnameu_weluuosupathusplitu__file__ujoinudllnameulogtypeuAddSourceToRegistryuEVENTLOG_ERROR_TYPEudeftypeuEVENTLOG_INFORMATION_TYPEuDEBUGuINFOuEVENTLOG_WARNING_TYPEuWARNINGuERRORuCRITICALutypemapuImportErroruprintuNone(uselfuappnameudllnameulogtypeuwin32evtlogutiluwin32evtlog((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyu__init__�s,
uNTEventLogHandler.__init__cCsdS(uy
Return the message ID for the event record. If you are using your
own messages, you could do this by having the msg passed to the
logger being an ID rather than a formatting string. Then, in here,
you could use a dictionary lookup to get the message ID. This
version returns 1, which is the base message ID in win32service.pyd.
i((uselfurecord((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyugetMessageID�suNTEventLogHandler.getMessageIDcCsdS(u�
Return the event category for the record.
Override this if you want to specify your own categories. This version
returns 0.
i((uselfurecord((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyugetEventCategorysu"NTEventLogHandler.getEventCategorycCs|jj|j|j�S(u�
Return the event type for the record.
Override this if you want to specify your own types. This version does
a mapping using the handler's typemap attribute, which is set up in
__init__() to a dictionary which contains mappings for DEBUG, INFO,
WARNING, ERROR and CRITICAL. If you are using your own levels you will
either need to override this method or place a suitable dictionary in
the handler's typemap attribute.
(utypemapugetulevelnoudeftype(uselfurecord((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyugetEventTypesuNTEventLogHandler.getEventTypecCs�|jr�yb|j|�}|j|�}|j|�}|j|�}|jj|j||||g�Wq�ttfk
r��Yq�|j |�Yq�XndS(u�
Emit a record.
Determine the message ID, event category and event type. Then
log the message in the NT event log.
N(
u_weluugetMessageIDugetEventCategoryugetEventTypeuformatuReportEventuappnameuKeyboardInterruptu
SystemExituhandleError(uselfurecorduiducatutypeumsg((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyuemits &uNTEventLogHandler.emitcCstjj|�dS(uS
Clean up this handler.
You can remove the application name from the registry as a
source of event log entries. However, if you do this, you will
not be able to see the events as you intended in the Event Log
Viewer - it needs to be able to access the registry to get the
DLL name.
N(ulogginguHandleruclose(uself((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyuclose,suNTEventLogHandler.closeN(u__name__u
__module__u__qualname__u__doc__uNoneu__init__ugetMessageIDugetEventCategoryugetEventTypeuemituclose(u
__locals__((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyuNTEventLogHandler�s
uNTEventLogHandlercBsG|EeZdZdZdd
d dd�Zdd�Zdd�Zd S(uHTTPHandleru^
A class which sends records to a Web server, using either GET or
POST semantics.
uGETcCshtjj|�|j�}|dkr7td��n||_||_||_||_||_ dS(ur
Initialize the instance with the host, the request URL, and the method
("GET" or "POST")
uGETuPOSTumethod must be GET or POSTN(uGETuPOST(
ulogginguHandleru__init__uupperu
ValueErroruhostuurlumethodusecureucredentials(uselfuhostuurlumethodusecureucredentials((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyu__init__>s uHTTPHandler.__init__cCs|jS(u�
Default implementation of mapping the log record into a dict
that is sent as the CGI data. Overwrite in your class.
Contributed by Franz Glasner.
(u__dict__(uselfurecord((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyumapLogRecordMsuHTTPHandler.mapLogRecordcCsy�ddl}ddl}|j}|jrB|jj|�}n|jj|�}|j}|jj |j
|��}|jdkr�|jd�dkr�d}nd}|d||f}n|j
|j|�|jd�} | dkr|d| �}n|jd|�|jd krQ|jd
d�|jdtt|���n|jr�ddl}
d
|jjd�}d|
j|�j�}|jd|�n|j�|jd kr�|j|jd��n|j�Wn/ttfk
r�Yn|j|�YnXdS(uk
Emit a record.
Send the record to the Web server as a percent-encoded dictionary
iNuGETu?u&u%c%su:uHostuPOSTuContent-typeu!application/x-www-form-urlencodeduContent-lengthuu%s:%suutf-8uBasic u
Authorization(uhttp.clientuurllib.parseuhostusecureuclientuHTTPSConnectionuHTTPConnectionuurluparseu urlencodeumapLogRecordumethodufindu
putrequestu putheaderustrulenucredentialsubase64uencodeu b64encodeustripu
endheadersusendugetresponseuKeyboardInterruptu
SystemExituhandleError(uselfurecorduhttpuurllibuhostuhuurludatausepuiubase64us((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyuemitUsF
uHTTPHandler.emitNF( u__name__u
__module__u__qualname__u__doc__uFalseuNoneu__init__umapLogRecorduemit(u
__locals__((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyuHTTPHandler9suHTTPHandlercBsV|EeZdZdZdd�Zdd�Zdd�Zdd �Zd
d�ZdS(
uBufferingHandleru�
A handler class which buffers logging records in memory. Whenever each
record is added to the buffer, a check is made to see if the buffer should
be flushed. If it should, then flush() is expected to do what's needed.
cCs&tjj|�||_g|_dS(u>
Initialize the handler with the buffer size.
N(ulogginguHandleru__init__ucapacityubuffer(uselfucapacity((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyu__init__�s uBufferingHandler.__init__cCst|j�|jkS(u�
Should the handler flush its buffer?
Returns true if the buffer is up to capacity. This method can be
overridden to implement custom flushing strategies.
(ulenubufferucapacity(uselfurecord((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyushouldFlush�suBufferingHandler.shouldFlushcCs0|jj|�|j|�r,|j�ndS(u�
Emit a record.
Append the record. If shouldFlush() tells us to, call flush() to process
the buffer.
N(ubufferuappendushouldFlushuflush(uselfurecord((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyuemit�suBufferingHandler.emitc
Cs)|j�z
g|_Wd|j�XdS(uw
Override to implement custom flushing behaviour.
This version just zaps the buffer to empty.
N(uacquireubufferurelease(uself((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyuflush�s
uBufferingHandler.flushcCs|j�tjj|�dS(up
Close the handler.
This version just flushes and chains to the parent class' close().
N(uflushulogginguHandleruclose(uself((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyuclose�s
uBufferingHandler.closeN( u__name__u
__module__u__qualname__u__doc__u__init__ushouldFlushuemituflushuclose(u
__locals__((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyuBufferingHandler�s uBufferingHandlercBs_|EeZdZdZejddd�Zdd�Zdd�Z dd �Z
d
d�ZdS(
u
MemoryHandleru�
A handler class which buffers logging records in memory, periodically
flushing them to a target handler. Flushing occurs whenever the buffer
is full, or when an event of a certain severity or greater is seen.
cCs&tj||�||_||_dS(u
Initialize the handler with the buffer size, the level at which
flushing should occur and an optional target.
Note that without a target being set either here or via setTarget(),
a MemoryHandler is no use to anyone!
N(uBufferingHandleru__init__u
flushLevelutarget(uselfucapacityu
flushLevelutarget((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyu__init__�s uMemoryHandler.__init__cCs(t|j�|jkp'|j|jkS(uP
Check for buffer full or a record at the flushLevel or higher.
(ulenubufferucapacityulevelnou
flushLevel(uselfurecord((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyushouldFlush�suMemoryHandler.shouldFlushcCs
||_dS(u:
Set the target handler for this handler.
N(utarget(uselfutarget((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyu setTarget�suMemoryHandler.setTargetc
CsY|j�z=|jrFx!|jD]}|jj|�q Wg|_nWd|j�XdS(u�
For a MemoryHandler, flushing means just sending the buffered
records to the target, if there is one. Override if you want
different behaviour.
The record buffer is also cleared by this operation.
N(uacquireutargetubufferuhandleurelease(uselfurecord((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyuflush�s
uMemoryHandler.flushc
Cs@|j�|j�zd|_tj|�Wd|j�XdS(uD
Flush, set the target to None and lose the buffer.
N(uflushuacquireuNoneutargetuBufferingHandlerucloseurelease(uself((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyuclose�s
uMemoryHandler.closeN(u__name__u
__module__u__qualname__u__doc__ulogginguERRORuNoneu__init__ushouldFlushu setTargetuflushuclose(u
__locals__((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyu
MemoryHandler�su
MemoryHandlercBsJ|EeZdZdZdd�Zdd�Zdd�Zdd �Zd
S(uQueueHandleru�
This handler sends events to a queue. Typically, it would be used together
with a multiprocessing Queue to centralise logging to file in one process
(in a multi-process application), so as to avoid file write contention
between processes.
This code is new in Python 3.2, but this class can be copy pasted into
user code for use with earlier Python versions.
cCstjj|�||_dS(uA
Initialise an instance, using the passed queue.
N(ulogginguHandleru__init__uqueue(uselfuqueue((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyu__init__suQueueHandler.__init__cCs|jj|�dS(u�
Enqueue a record.
The base implementation uses put_nowait. You may want to override
this method if you want to use blocking, timeouts or custom queue
implementations.
N(uqueueu
put_nowait(uselfurecord((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyuenqueue suQueueHandler.enqueuecCs/|j|�|j|_d|_d|_|S(u�
Prepares a record for queuing. The object returned by this method is
enqueued.
The base implementation formats the record to merge the message
and arguments, and removes unpickleable items from the record
in-place.
You might want to override this method if you want to convert
the record to a dict or JSON string, or send a modified copy
of the record while leaving the original intact.
N(uformatumessageumsguNoneuargsuexc_info(uselfurecord((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyuprepares
uQueueHandler.preparecCsPy|j|j|��Wn/ttfk
r7�Yn|j|�YnXdS(um
Emit a record.
Writes the LogRecord to the queue, preparing it for pickling first.
N(uenqueueuprepareuKeyboardInterruptu
SystemExituhandleError(uselfurecord((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyuemit,suQueueHandler.emitN(u__name__u
__module__u__qualname__u__doc__u__init__uenqueueuprepareuemit(u
__locals__((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyuQueueHandler�s
uQueueHandlercBs�|EeZdZdZdZdd�Zdd�Zdd�Zdd �Z d
d�Z
dd
�Zdd�Zdd�Z
dS(u
QueueListeneru�
This class implements an internal threaded listener which watches for
LogRecords being added to a queue, removes them and passes them to a
list of handlers for processing.
cGs.||_||_tj�|_d|_dS(uc
Initialise an instance with the specified queue and
handlers.
N(uqueueuhandlersu threadinguEventu_stopuNoneu_thread(uselfuqueueuhandlers((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyu__init__Bs uQueueListener.__init__cCs|jj|�S(u�
Dequeue a record and return it, optionally blocking.
The base implementation uses get. You may want to override this method
if you want to use timeouts or work with custom queue implementations.
(uqueueuget(uselfublock((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyudequeueLsuQueueListener.dequeuecCs7tjd|j�|_}|jd�|j�dS(u�
Start the listener.
This starts up a background thread to monitor the queue for
LogRecords to process.
utargetNT(u threadinguThreadu_monitoru_threadu setDaemonuTrueustart(uselfut((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyustartUs
uQueueListener.startcCs|S(u
Prepare a record for handling.
This method just returns the passed-in record. You may want to
override this method if you need to do any custom marshalling or
manipulation of the record before passing it to the handlers.
((uselfurecord((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyuprepare`suQueueListener.preparecCs4|j|�}x|jD]}|j|�qWdS(u�
Handle a record.
This just loops through the handlers offering them the record
to handle.
N(uprepareuhandlersuhandle(uselfurecorduhandler((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyuhandlejsuQueueListener.handlecCs�|j}t|d�}xq|jj�s�yF|jd�}||jkrOPn|j|�|ro|j�nWqtj k
r�YqXqWxbyF|jd�}||jkr�Pn|j|�|r�|j�nWq�tj k
r�PYq�Xq�dS(u�
Monitor the queue for records, and ask the handler
to deal with them.
This method runs on a separate, internal thread.
The thread will terminate if it sees a sentinel object in the queue.
u task_doneNTF(uqueueuhasattru_stopuisSetudequeueuTrueu _sentineluhandleu task_doneuEmptyuFalse(uselfuqu
has_task_doneurecord((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyu_monitorus,
uQueueListener._monitorcCs|jj|j�dS(u
This is used to enqueue the sentinel record.
The base implementation uses put_nowait. You may want to override this
method if you want to use timeouts or work with custom queue
implementations.
N(uqueueu
put_nowaitu _sentinel(uself((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyuenqueue_sentinel�suQueueListener.enqueue_sentinelcCs1|jj�|j�|jj�d|_dS(u!
Stop the listener.
This asks the thread to terminate, and then waits for it to do so.
Note that if you don't call this before your application exits, there
may be some records still left on the queue, which won't be processed.
N(u_stopusetuenqueue_sentinelu_threadujoinuNone(uself((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyustop�s
uQueueListener.stopN(u__name__u
__module__u__qualname__u__doc__uNoneu _sentinelu__init__udequeueustartuprepareuhandleu_monitoruenqueue_sentinelustop(u
__locals__((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyu
QueueListener:s
u
QueueListeneri�i�Q(+u__doc__uerrnouloggingusocketuosupickleustructutimeureucodecsuBOM_UTF8ustatuST_DEVuST_INOuST_MTIMEuqueueu threadinguImportErroruNoneuDEFAULT_TCP_LOGGING_PORTuDEFAULT_UDP_LOGGING_PORTuDEFAULT_HTTP_LOGGING_PORTuDEFAULT_SOAP_LOGGING_PORTuSYSLOG_UDP_PORTuSYSLOG_TCP_PORTu _MIDNIGHTuFileHandleruBaseRotatingHandleruRotatingFileHandleruTimedRotatingFileHandleruWatchedFileHandleruHandleru
SocketHandleruDatagramHandleru
SysLogHandleruSMTPHandleruNTEventLogHandleruHTTPHandleruBufferingHandleru
MemoryHandleruQueueHandleruobjectu
QueueListener(((u5/opt/alt/python33/lib64/python3.3/logging/handlers.pyu<module>s<`
HL�>�&�PdJ7=B
?>