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KO}ӽmSşذqsOy?\[,d@'73'j%kOe`1.g2"e =YIzS2|zŐƄa\U,dP;jhhhaxǶ?КZ՚.q SE+XrbOu%\GتX(H,N^~]JyEZQKceTQ]VGYqnah;y$cQahT&QPZ*iZ8UQQM.qo/T\7X"u?Mttl2Xq(IoW{R^ ux*SYJ! 4S.Jy~ BROS[V|žKNɛP(L6V^|cR7i7nZW1Fd@ Ara{詑|(T*dN]Ko?s=@ |_EvF]׍kR)eBJc" MUUbY6`~V޴dJKß&~'d3i WWWWWW
Current Directory: /usr/lib64/python3.6/logging/__pycache__
Viewing File: /usr/lib64/python3.6/logging/__pycache__/handlers.cpython-36.pyc
3 \��� @s�dZddlZddlZddlZddlZddlZddlZddlZddlm Z m Z m Z ddl Z y ddl Z Wnek r|dZ YnXdZdZdZdZdZdZd(ZGd d �d ej�ZGd d�de�ZGdd�de�ZGdd�dej�ZGdd�dej�ZGdd�de�ZGdd�dej�ZGdd�dej�ZGdd�dej�Z Gdd�dej�Z!Gdd �d ej�Z"Gd!d"�d"e"�Z#Gd#d$�d$ej�Z$e �r�Gd%d&�d&e%�Z&dS))z� 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-2016 Vinay Sajip. All Rights Reserved. To use, simply 'import logging.handlers' and log away! �N)�ST_DEV�ST_INO�ST_MTIMEi<#i=#i>#i?#i��<c@s2eZdZdZd dd�Zdd�Zdd �Zd d �ZdS) �BaseRotatingHandlerz� Base class for handlers that rotate log files at a certain point. Not meant to be instantiated directly. Instead, use RotatingFileHandler or TimedRotatingFileHandler. NFcCs0tjj|||||�||_||_d|_d|_dS)zA Use the specified filename for streamed logging N)�logging� FileHandler�__init__�mode�encoding�namer�rotator)�self�filenamer r �delay�r� /usr/lib64/python3.6/handlers.pyr 5s zBaseRotatingHandler.__init__c CsHy$|j|�r|j�tjj||�Wntk rB|j|�YnXdS)z� Emit a record. Output the record to the file, catering for rollover as described in doRollover(). N)�shouldRollover� doRolloverrr �emit� Exception� handleError)r�recordrrrr?s  zBaseRotatingHandler.emitcCst|j�s|}n |j|�}|S)a� 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. )�callabler )rZ default_name�resultrrr�rotation_filenameMs  z%BaseRotatingHandler.rotation_filenamecCs4t|j�s$tjj|�r0tj||�n |j||�dS)aL 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)rr�os�path�exists�rename)r�source�destrrr�rotate`s  zBaseRotatingHandler.rotate)NF)�__name__� __module__� __qualname__�__doc__r rrr#rrrrr/s  rc@s*eZdZdZd dd�Zdd �Zd d �ZdS) �RotatingFileHandlerz� Handler for logging to a set of files, which switches from one file to the next when the current file reaches a certain size. �arNFcCs.|dkr d}tj|||||�||_||_dS)a� 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. rr)N)rr �maxBytes� backupCount)rrr r*r+r rrrrr zs zRotatingFileHandler.__init__cCs�|jr|jj�d|_|jdkr�xtt|jddd�D]^}|jd|j|f�}|jd|j|df�}tjj|�r4tjj|�r�tj |�tj ||�q4W|j|jd�}tjj|�r�tj |�|j |j|�|j s�|j �|_dS)z< Do a rollover, as described in __init__(). Nr�z%s.%dz.1���)�stream�closer+�ranger� baseFilenamerrr�remover r#r�_open)r�iZsfn�dfnrrrr�s$        zRotatingFileHandler.doRollovercCsZ|jdkr|j�|_|jdkrVd|j|�}|jjdd�|jj�t|�|jkrVdSdS)z� Determine if rollover should occur. Basically, see if the supplied record would cause the file to exceed the size limit we have. Nrz%s �r,)r.r3r*�format�seek�tell�len)rr�msgrrrr�s   z"RotatingFileHandler.shouldRollover)r)rrNF)r$r%r&r'r rrrrrrr(us r(c@s:eZdZdZddd�Zd d �Zd d �Zd d�Zdd�ZdS)�TimedRotatingFileHandlerz� 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. �hr,rNFc Cs�tj||d||�|j�|_||_||_||_|jdkrNd|_d|_d|_ �n�|jdkrld|_d|_d |_ n�|jd kr�d|_d |_d |_ n�|jd ks�|jdkr�d|_d|_d|_ n�|jj d��r.d|_t |j�dkr�t d|j��|jddk�s|jddk�rt d|j��t |jd�|_d|_d|_ nt d|j��tj|j tj�|_ |j||_|j}tjj|��r~tj|�t} n t tj��} |j| �|_dS) Nr)�Sr,z%Y-%m-%d_%H-%M-%Sz-^\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2}(\.\w+)?$�Mrz%Y-%m-%d_%H-%Mz'^\d{4}-\d{2}-\d{2}_\d{2}-\d{2}(\.\w+)?$�Hz %Y-%m-%d_%Hz!^\d{4}-\d{2}-\d{2}_\d{2}(\.\w+)?$�D�MIDNIGHTrz%Y-%m-%dz^\d{4}-\d{2}-\d{2}(\.\w+)?$�W�r6zHYou must specify a day for weekly rollover from 0 to 6 (0 is Monday): %s�0�6z-Invalid day specified for weekly rollover: %sz'Invalid rollover interval specified: %siii�Qii�Qi�: )rr �upper�whenr+�utc�atTime�interval�suffix�extMatch� startswithr:� ValueError�int� dayOfWeek�re�compile�ASCIIr1rrr�statr�time�computeRollover� rolloverAt) rrrHrKr+r rrIrJ�trrrr �sL        z!TimedRotatingFileHandler.__init__cCsd||j}|jdks"|jjd��r`|jr4tj|�}n tj|�}|d}|d}|d}|d}|jdkrnt}n |jj d|jj d|jj }||d|d|} | d kr�| t7} |d d }|| }|jjd��r`|} | |j k�r`| |j kr�|j | } nd| |j d } || d} |j�s\|d} tj| �d}| |k�r\| �sPd}nd }| |7} | }|S)zI Work out the rollover time based on the specified time. rBrC����Nrrr,rDriii�Qr-r-i��) rKrHrNrIrV�gmtime� localtimerJ� _MIDNIGHTZhourZminute�secondrQ)r� currentTimerrYZ currentHourZ currentMinuteZ currentSecondZ currentDayZ rotate_ts�rZdayZ daysToWait� newRolloverAt�dstNow� dstAtRollover�addendrrrrWsH           z(TimedRotatingFileHandler.computeRollovercCsttj��}||jkrdSdS)z� 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 r,r)rPrVrX)rrrYrrrrKs  z'TimedRotatingFileHandler.shouldRolloverc Cs�tjj|j�\}}tj|�}g}|d}t|�}xH|D]@}|d|�|kr6||d�}|jj|�r6|jtjj ||��q6Wt|�|j kr�g}n|j �|dt|�|j �}|S)z� Determine the files to delete when rolling over. More specific than the earlier method, which just used glob.glob(). �.N) rr�splitr1�listdirr:rM�match�append�joinr+�sort) rZdirNameZbaseNameZ fileNamesr�prefixZplenZfileNamerLrrr�getFilesToDeleteWs    z)TimedRotatingFileHandler.getFilesToDeletec Cs�|jr|jj�d|_ttj��}tj|�d}|j|j}|jrNtj|�}n6tj|�}|d }||kr�|rrd}nd }tj||�}|j |j dtj |j |��}t jj|�r�t j|�|j|j |�|jdkr�x|j�D]}t j|�q�W|j�s�|j�|_|j|�} x| |k�r"| |j} �q W|jdk�s>|jjd��rx|j �rxtj| �d } || k�rx|�sld }nd}| |7} | |_dS) ax 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. Nr,irhrrBrCr-r-i��r-i��)r.r/rPrVr_rXrKrIr^rr1ZstrftimerLrrrr2r#r+rprr3rWrHrN) rrbrerYZ timeTupleZdstThenrgr5�srdrfrrrrnsH            $ z#TimedRotatingFileHandler.doRollover)r=r,rNFFN) r$r%r&r'r rWrrprrrrrr<�s  9I r<c@s2eZdZdZd dd�Zdd�Zd d �Zd d �ZdS)�WatchedFileHandlera� 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. r)NFcCs,tjj|||||�d\|_|_|j�dS)Nr,r-r-)r-r-)rr r �dev�ino� _statstream)rrr r rrrrr �s zWatchedFileHandler.__init__cCs0|jr,tj|jj��}|t|t|_|_dS)N)r.r�fstat�filenorrrsrt)r�sresrrrru�szWatchedFileHandler._statstreamc Cs�ytj|j�}Wntk r(d}YnX| sL|t|jksL|t|jkr�|jdk r�|jj �|jj �d|_|j �|_|j �dS)z� Reopen log file if needed. Checks if the underlying file has changed, and if it has, close the old stream and reopen the file to get the current stream. N) rrUr1�FileNotFoundErrorrrsrrtr.�flushr/r3ru)rrxrrr�reopenIfNeeded�s  "    z!WatchedFileHandler.reopenIfNeededcCs|j�tjj||�dS)z� Emit a record. If underlying file has changed, reopen the file before emitting the record to it. N)r{rr r)rrrrrr�szWatchedFileHandler.emit)r)NF)r$r%r&r'r rur{rrrrrrr�s  rrc@sReZdZdZdd�Zddd�Zdd�Zd d �Zd d �Zd d�Z dd�Z dd�Z dS)� SocketHandlera 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. cCsZtjj|�||_||_|dkr(||_n ||f|_d|_d|_d|_d|_ d|_ d|_ dS)a 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. NFg�?g>@g@) r�Handlerr �host�port�address�sock� closeOnError� retryTime� retryStart�retryMax� retryFactor)rr~rrrrr �s  zSocketHandler.__init__r,c Csj|jdk rtj|j|d�}nJtjtjtj�}|j|�y|j|j�Wntk rd|j ��YnX|S)zr A factory method which allows subclasses to define the precise type of socket they want. N)�timeout) r�socketZcreate_connectionr��AF_UNIX� SOCK_STREAMZ settimeout�connect�OSErrorr/)rr�rrrr� makeSocket s  zSocketHandler.makeSocketc Cs�tj�}|jdkrd}n ||jk}|r�y|j�|_d|_WnVtk r�|jdkr^|j|_n"|j|j|_|j|jkr�|j|_||j|_YnXdS)z� 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) rVr�r�r�r�r�Z retryPeriodr�r�)rZnowZattemptrrr� createSockets       zSocketHandler.createSocketc CsR|jdkr|j�|jrNy|jj|�Wn$tk rL|jj�d|_YnXdS)z� Send a pickled string to the socket. This function allows for partial sends which can happen when the network is busy. N)r�r��sendallr�r/)rrqrrr�send8s  zSocketHandler.sendcCsj|j}|r|j|�}t|j�}|j�|d<d|d<d|d<|jdd�tj|d�}tj dt |��}||S)z� Pickles the record in binary format with a length prefix, and returns it ready for transmission across the socket. r;N�args�exc_info�messager,z>L) r�r7�dict�__dict__Z getMessage�pop�pickle�dumps�struct�packr:)rrZeiZdummy�drqZslenrrr� makePickleKs     zSocketHandler.makePicklecCs0|jr|jr|jj�d|_ntjj||�dS)z� 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)r�r�r/rr}r)rrrrrras  zSocketHandler.handleErrorc Cs<y|j|�}|j|�Wntk r6|j|�YnXdS)a 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)r�r�rr)rrrqrrrros  zSocketHandler.emitc Cs@|j�z(|j}|r"d|_|j�tjj|�Wd|j�XdS)z$ Closes the socket. N)�acquirer�r/rr}�release)rr�rrrr/~szSocketHandler.closeN)r,) r$r%r&r'r r�r�r�r�rrr/rrrrr|�s  r|c@s(eZdZdZdd�Zdd�Zdd�ZdS) �DatagramHandlera� 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. cCstj|||�d|_dS)zP Initializes the handler with a specific host address and port. FN)r|r r�)rr~rrrrr �szDatagramHandler.__init__cCs*|jdkrtj}ntj}tj|tj�}|S)zu The factory method of SocketHandler is here overridden to create a UDP socket (SOCK_DGRAM). N)rr�r�ZAF_INET� SOCK_DGRAM)rZfamilyrqrrrr��s  zDatagramHandler.makeSocketcCs&|jdkr|j�|jj||j�dS)z� 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)r�r��sendtor�)rrqrrrr��s zDatagramHandler.sendN)r$r%r&r'r r�r�rrrrr��s  r�c@s"eZdZdZdZdZdZdZdZdZ dZ d Z dZ dZ dZdZdZdZdZd Zd Zd Zd Zd ZdZdZdZdZdZdZdZdZeeee eeee e eeed� Z eeeeee eeeeee eeeeeeeeed�Z!dddddd�Z"de#fe dfd d!�Z$d"d#�Z%d$d%�Z&d&d'�Z'd(d)�Z(d*Z)d+Z*d,d-�Z+dS).� SysLogHandlera 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). rr,r6rZr[r\r]rD�� � � ��������) ZalertZcrit�critical�debugZemerg�err�error�infoZnoticeZpanic�warn�warning)ZauthZauthprivZcron�daemonZftpZkernZlprZmailZnewsZsecurityZsyslog�userZuucpZlocal0Zlocal1Zlocal2Zlocal3Zlocal4Zlocal5Zlocal6Zlocal7r�r�r�r�r�)�DEBUG�INFO�WARNING�ERROR�CRITICALZ localhostNcCs0tjj|�||_||_||_t|t�rTd|_y|j |�Wnt k rPYnXn�d|_|dkrht j }|\}}t j ||d|�}|s�t d��x�|D]|}|\}}} } } d} } y(t j ||| �} |t jkr�| j| �PWq�t k �r }z|} | dk r�| j�WYdd}~Xq�Xq�W| dk �r | �| |_ ||_dS)a 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. If socktype is specified as socket.SOCK_DGRAM or socket.SOCK_STREAM, that specific socket type will be used. For Unix sockets, you can also specify a socktype of None, in which case socket.SOCK_DGRAM will be used, falling back to socket.SOCK_STREAM. TFNrz!getaddrinfo returns an empty list)rr}r r��facility�socktype� isinstance�str� unixsocket�_connect_unixsocketr�r�r�Z getaddrinfor�r�r/)rr�r�r�r~rZress�resZaf�proto�_Zsar�r��excrrrr sB      zSysLogHandler.__init__cCs�|j}|dkrtj}tjtj|�|_y|jj|�||_Wnxtk r�|jj�|jdk r`�tj}tjtj|�|_y|jj|�||_Wn tk r�|jj��YnXYnXdS)N)r�r�r�r�r�r�r/r�)rr�Z use_socktyperrrr�Ss&       z!SysLogHandler._connect_unixsocketcCs4t|t�r|j|}t|t�r(|j|}|d>|BS)z� 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. rZ)r�r��facility_names�priority_names)rr�Zpriorityrrr�encodePriorityks     zSysLogHandler.encodePriorityc Cs2|j�z|jj�tjj|�Wd|j�XdS)z$ Closes the socket. N)r�r�r/rr}r�)rrrrr/xs  zSysLogHandler.closecCs|jj|d�S)aK 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). r�)� priority_map�get)rZ levelNamerrr� mapPriority�szSysLogHandler.mapPriority�TcCsy�|j|�}|jr|j|}|jr*|d7}d|j|j|j|j��}|jd�}|jd�}||}|jr�y|j j |�Wq�t k r�|j j �|j |j�|j j |�Yq�Xn*|jt jkr�|j j||j�n |j j|�Wntk r�|j|�YnXdS)z� 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. �z<%d>zutf-8N)r7�ident� append_nulr�r�r�Z levelname�encoder�r�r�r�r/r�r�r�r�r�r�rr)rrr;Zpriorrrr�s.        zSysLogHandler.emit),r$r%r&r'Z LOG_EMERGZ LOG_ALERTZLOG_CRITZLOG_ERRZ LOG_WARNINGZ LOG_NOTICEZLOG_INFOZ LOG_DEBUGZLOG_KERNZLOG_USERZLOG_MAILZ LOG_DAEMONZLOG_AUTHZ LOG_SYSLOGZLOG_LPRZLOG_NEWSZLOG_UUCPZLOG_CRONZ LOG_AUTHPRIVZLOG_FTPZ LOG_LOCAL0Z LOG_LOCAL1Z LOG_LOCAL2Z LOG_LOCAL3Z LOG_LOCAL4Z LOG_LOCAL5Z LOG_LOCAL6Z LOG_LOCAL7r�r�r��SYSLOG_UDP_PORTr r�r�r/r�r�r�rrrrrr��s� 5   r�c@s*eZdZdZd dd�Zdd�Zdd �ZdS) � SMTPHandlerzK A handler class which sends an SMTP email for each logging event. N�@cCs�tjj|�t|ttf�r(|\|_|_n|d|_|_t|ttf�rR|\|_|_ nd|_||_ t|t �rn|g}||_ ||_ ||_||_dS)ax 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)rr}r r��list�tuple�mailhost�mailport�username�password�fromaddrr��toaddrs�subject�securer�)rr�r�r�r�� credentialsr�r�rrrr �s  zSMTPHandler.__init__cCs|jS)z� Determine the subject for the email. If you want to specify a subject line which is record-dependent, override this method. )r�)rrrrr� getSubject�szSMTPHandler.getSubjectc Csy�ddl}ddlm}ddl}|j}|s.|j}|j|j||jd�}|�}|j |d<dj |j �|d<|j |�|d<|j j�|d <|j|j|��|jr�|jdk r�|j�|j|j�|j�|j|j|j�|j|�|j�Wntk r�|j|�YnXdS) zd Emit a record. Format the record and send it to the specified addressees. rN)� EmailMessage)r�ZFrom�,ZToZSubjectZDate)�smtplibZ email.messager�Z email.utilsr�Z SMTP_PORTZSMTPr�r�r�rmr�r�Zutilsr_Z set_contentr7r�r�ZehloZstarttlsZloginr�Z send_message�quitrr)rrr�r�ZemailrZsmtpr;rrrr�s0      zSMTPHandler.emit)NNr�)r$r%r&r'r r�rrrrrr��s " r�c@sBeZdZdZddd�Zdd�Zdd �Zd d �Zd d �Zdd�Z dS)�NTEventLogHandlera� 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. N� ApplicationcCs�tjj|�y�ddl}ddl}||_||_|s`tjj |jj �}tjj |d�}tjj |dd�}||_ ||_ |jj|||�|j|_tj|jtj|jtj|jtj|jtj|ji|_Wn"tk r�td�d|_YnXdS)Nrzwin32service.pydzWThe Python Win32 extensions for NT (service, event logging) appear not to be available.)rr}r �win32evtlogutil� win32evtlog�appname�_welurrri�__file__rm�dllname�logtypeZAddSourceToRegistryZEVENTLOG_ERROR_TYPE�deftyper�ZEVENTLOG_INFORMATION_TYPEr�r�ZEVENTLOG_WARNING_TYPEr�r��typemap� ImportError�print)rr�r�r�r�r�rrrr s* zNTEventLogHandler.__init__cCsdS)ay 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. r,r)rrrrr� getMessageID(szNTEventLogHandler.getMessageIDcCsdS)z� Return the event category for the record. Override this if you want to specify your own categories. This version returns 0. rr)rrrrr�getEventCategory2sz"NTEventLogHandler.getEventCategorycCs|jj|j|j�S)a� 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. )r�r��levelnor�)rrrrr� getEventType;s zNTEventLogHandler.getEventTypec Csn|jrjyD|j|�}|j|�}|j|�}|j|�}|jj|j||||g�Wntk rh|j|�YnXdS)z� Emit a record. Determine the message ID, event category and event type. Then log the message in the NT event log. N) r�r�r�r�r7Z ReportEventr�rr)rr�id�cat�typer;rrrrHs    zNTEventLogHandler.emitcCstjj|�dS)aS 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)rr}r/)rrrrr/Ys zNTEventLogHandler.close)Nr�) r$r%r&r'r r�r�r�rr/rrrrr�s     r�c@s*eZdZdZd dd�Zdd�Zd d �ZdS) � HTTPHandlerz^ A class which sends records to a Web server, using either GET or POST semantics. �GETFNcCsbtjj|�|j�}|dkr$td��| r:|dk r:td��||_||_||_||_||_ ||_ dS)zr Initialize the instance with the host, the request URL, and the method ("GET" or "POST") r��POSTzmethod must be GET or POSTNz3context parameter only makes sense with secure=True)r�r�) rr}r rGrOr~�url�methodr�r��context)rr~r�r�r�r�r�rrrr ks zHTTPHandler.__init__cCs|jS)z� 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. )r�)rrrrr� mapLogRecordszHTTPHandler.mapLogRecordc Csx�yPddl}ddl}|j}|jr4|jj||jd�}n |jj|�}|j}|j j |j |��}|j dkr�|j d�dkrvd}nd}|d||f}|j|j |�|j d�} | dkr�|d| �}|j d kr�|jd d �|jd tt|���|j�r$ddl} d |jjd�} d| j| �j�jd�} |jd| �|j�|j d k�rH|j|jd��|j�Wn tk �rr|j|�YnXdS)zk Emit a record. Send the record to the Web server as a percent-encoded dictionary rN)r�r��?�&z%c%s�:r�z Content-typez!application/x-www-form-urlencodedzContent-lengthz%s:%szutf-8zBasic �asciiZ Authorization)Z http.clientZ urllib.parser~r�ZclientZHTTPSConnectionr�ZHTTPConnectionr��parseZ urlencoder�r��findZ putrequestZ putheaderr�r:r��base64r�Z b64encode�strip�decodeZ endheadersr�Z getresponserr) rrZhttpZurllibr~r=r��data�sepr4rrqrrrr�s@        zHTTPHandler.emit)r�FNN)r$r%r&r'r r�rrrrrr�fs  r�c@s8eZdZdZdd�Zdd�Zdd�Zdd �Zd d �Zd S) �BufferingHandlerz� 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. cCstjj|�||_g|_dS)z> Initialize the handler with the buffer size. N)rr}r �capacity�buffer)rr rrrr �s zBufferingHandler.__init__cCst|j�|jkS)z� 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. )r:r r )rrrrr� shouldFlush�szBufferingHandler.shouldFlushcCs"|jj|�|j|�r|j�dS)z� Emit a record. Append the record. If shouldFlush() tells us to, call flush() to process the buffer. N)r rlrrz)rrrrrr�s  zBufferingHandler.emitc Cs"|j�z g|_Wd|j�XdS)zw Override to implement custom flushing behaviour. This version just zaps the buffer to empty. N)r�r r�)rrrrrz�s zBufferingHandler.flushc Cs z |j�Wdtjj|�XdS)zp Close the handler. This version just flushes and chains to the parent class' close(). N)rzrr}r/)rrrrr/�s zBufferingHandler.closeN) r$r%r&r'r rrrzr/rrrrr �s    r c@sBeZdZdZejddfdd�Zdd�Zdd �Zd d �Z d d �Z dS)� MemoryHandlerz� 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. NTcCs"tj||�||_||_||_dS)a; 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! The ``flushOnClose`` argument is ``True`` for backward compatibility reasons - the old behaviour is that when the handler is closed, the buffer is flushed, even if the flush level hasn't been exceeded nor the capacity exceeded. To prevent this, set ``flushOnClose`` to ``False``. N)r r � flushLevel�target� flushOnClose)rr rrrrrrr �s zMemoryHandler.__init__cCst|j�|jkp|j|jkS)zP Check for buffer full or a record at the flushLevel or higher. )r:r r r�r)rrrrrrszMemoryHandler.shouldFlushcCs ||_dS)z: Set the target handler for this handler. N)r)rrrrr� setTargetszMemoryHandler.setTargetc CsD|j�z,|jr2x|jD]}|jj|�qWg|_Wd|j�XdS)z� 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)r�rr �handler�)rrrrrrzs  zMemoryHandler.flushcCsBz|jr|j�Wd|j�zd|_tj|�Wd|j�XXdS)zi Flush, if appropriately configured, set the target to None and lose the buffer. N)rrzr�rr r/r�)rrrrr/&s zMemoryHandler.close) r$r%r&r'rr�r rrrzr/rrrrr�s rc@s0eZdZdZdd�Zdd�Zdd�Zdd �Zd S) � QueueHandlera� 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)zA Initialise an instance, using the passed queue. N)rr}r �queue)rrrrrr Bs zQueueHandler.__init__cCs|jj|�dS)z� 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)r� put_nowait)rrrrr�enqueueIszQueueHandler.enqueuecCs"|j|�|j|_d|_d|_|S)a� 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)r7r�r;r�r�)rrrrr�prepareSs  zQueueHandler.preparec Cs8y|j|j|��Wntk r2|j|�YnXdS)zm Emit a record. Writes the LogRecord to the queue, preparing it for pickling first. N)rrrr)rrrrrrlszQueueHandler.emitN)r$r%r&r'r rrrrrrrr7s   rc@sZeZdZdZdZdd�dd�Zdd�Zd d �Zd d �Zd d�Z dd�Z dd�Z dd�Z dS)� QueueListenerz� 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. NF)�respect_handler_levelcGs||_||_d|_||_dS)zc Initialise an instance with the specified queue and handlers. N)r�handlers�_threadr)rrrrrrrr �szQueueListener.__init__cCs |jj|�S)z� 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. )rr�)r�blockrrr�dequeue�szQueueListener.dequeuecCs&tj|jd�|_}d|_|j�dS)z� Start the listener. This starts up a background thread to monitor the queue for LogRecords to process. )rTN)� threadingZThread�_monitorrr��start)rrYrrrr"�szQueueListener.startcCs|S)a 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. r)rrrrrr�szQueueListener.preparecCsD|j|�}x4|jD]*}|js"d}n |j|jk}|r|j|�qWdS)z� Handle a record. This just loops through the handlers offering them the record to handle. TN)rrrr��levelr)rrZhandlerZprocessrrrr�s   zQueueListener.handlec Csd|j}t|d�}xNy0|jd�}||jkr*P|j|�|r@|j�Wqtjk rZPYqXqWdS)z� 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. � task_doneTN)r�hasattrr� _sentinelrr$ZEmpty)r�qZ has_task_donerrrrr!�s     zQueueListener._monitorcCs|jj|j�dS)a 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)rrr&)rrrr�enqueue_sentinel�szQueueListener.enqueue_sentinelcCs|j�|jj�d|_dS)a! 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)r(rrm)rrrr�stop�s zQueueListener.stop) r$r%r&r'r&r rr"rrr!r(r)rrrrrxs     ri�i�Q)'r'rr�rr�r�rVrRrUrrrrr r�ZDEFAULT_TCP_LOGGING_PORTZDEFAULT_UDP_LOGGING_PORTZDEFAULT_HTTP_LOGGING_PORTZDEFAULT_SOAP_LOGGING_PORTr�ZSYSLOG_TCP_PORTr`r rr(r<rrr}r|r�r�r�r�r�r rr�objectrrrrr�<module>sB8  FL`E(*PbO9I@