
    wg\jX                     R    S SK Jr  S SKrS SKrS SKr " S S\R
                  5      rg)    Nc                      ^  \ rS rSrSrSrSr\rSrSr	Sr
SrSrS	rS
rS\R                   4\R"                  R$                  S
S
S4U 4S jjrS rSrU =r$ )WebsockifySysLogHandler   zV
A handler class that sends proper Syslog-formatted messages,
as defined by RFC 5424.
z<{pri}>{ident}[{pid}]: z2<{pri}>1 {timestamp} {hostname} {ident} {pid} - - Fz%Y-%m-%dT%H:%M:%SZ      
N	localhostc                 p   > X@l         U(       a  SU l        U R                  U l        [        TU ]  XU5        g)am  
Initialize a handler.

If address is specified as a string, a UNIX socket is used. To log to a
local syslogd, "WebsockifySysLogHandler(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. If ident is specified, this string will be
used as the application name in all messages sent. Set legacy to True
to use the old version of the protocol.
TN)ident_legacy_legacy_head_fmt	_head_fmtsuper__init__)selfaddressfacilitysocktyper   legacy	__class__s         S/home/edenadmin/noVNC/venv/lib/python3.13/site-packages/websockify/sysloghandler.pyr    WebsockifySysLogHandler.__init__   s0    " 
DL!22DNH5    c                     U R                  U5      R                  U R                  S5      nU(       d  gU R                  U R                  U R                  UR                  5      5      n[        R                  " U R                  [        R                  " 5       5      n[        R                  " 5       SU R                   nU R                  (       a  U R                  SU R                   nOSn[         R"                  " 5       nUUUUUS.nU R$                  R                   " S	0 UD6R'                  SS5      n	 XR'                  S5      -  n	U R*                  [        R,                  :w  aO  U R.                  (       a!  S[1        U	5      -  R'                  S5      U	-   n	OXR                  R'                  S5      -  n	U R2                  (       a   U R                  R5                  U	5        gU R*                  [        R,                  :X  a&  U R                  R=                  XR:                  5        gU R                  R?                  U	5        g! [(         a    XR'                  S5      -  n	 GNf = f! [6         a9    U R9                  U R:                  5        U R                  R5                  U	5         gf = f! [@        [B        4 a    e   U RE                  U5         g= f)
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.
 N )pri	timestamphostnamer   pidasciiignorez	utf-8-sigz%d  )#formatreplace_tailencodePriorityr   mapPriority	levelnametimestrftime_timestamp_fmtgmtimesocketgethostname_max_hostnamer   
_max_identosgetpidr   encodeUnicodeEncodeErrorr   
SOCK_DGRAM_send_lengthlen
unixsocketsendOSError_connect_unixsocketr   sendtosendallKeyboardInterrupt
SystemExithandleError)
r   recordtextr   r   r   r   r    headmsgs
             r   emitWebsockifySysLogHandler.emit2   s;   <	%;;v&..tzz3?D%%dmm&*&6&6v7G7G&HJC d&9&94;;=II))+,?T-?-?@Hzz

#3DOO4))+C &$D ..''/$/66wIC0{{7++
 }} 1 11$$ 3s8+33G<sBC::,,W55C *KK$$S) ==F$5$55KK&&sLL9KK'',- & 0{{;//0  *,,T\\:KK$$S)* ":. 		%V$sb   2J/ DJ/ 7I 
A>J/ 	I) %AJ/ )J/ I&"J/ %I&&J/ )A J,)J/ +J,,J/ /#K)r   r   r   )__name__
__module____qualname____firstlineno____doc__r   _rfc5424_head_fmtr   r   r,   r0   r1   r7   r&   r   handlersSYSLOG_UDP_PORTSysLogHandlerLOG_USERr   rF   __static_attributes____classcell__)r   s   @r   r   r      sw    
 1L!IG)NMJLE E !,X-E-EF"0099d564D% D%r   r   )logging.handlersrN   r.   r2   r*   rP   r   r#   r   r   <module>rU      s"    5 5 5r%h44 r%r   