
    Ii"(                     @   % S r SSKrSSKrSSKrSSKJrJrJrJr  SSKrSSK	r	SSK
JrJrJrJrJrJr  SSKJr  SSKJr  Sr\\S4   \S	'    SS
\R0                  S\S\\\4   S\\\\4      S\4
S jjr " S S\R4                  5      r " S S\R8                  5      rg)zh
This library is provided to allow standard python logging
to output log data as JSON formatted strings
    N)datedatetimetimetimezone)AnyDictOptionalUnionListTuple)istraceback)OrderedDict)argsasctimecreatedexc_infoexc_textfilenamefuncName	levelnamelevelnolinenomodulemsecsmessagemsgnamepathnameprocessprocessNamerelativeCreated
stack_infothread
threadName.RESERVED_ATTRSrecordtargetreservedrename_fieldsreturnc                     Uc  0 nU R                   R                  5        HH  u  pEXB;  d  M  [        US5      (       a  UR                  S5      (       a  M5  XQUR	                  XD5      '   MJ     U$ )aS  
Merges extra attributes from LogRecord object into target dictionary

:param record: logging.LogRecord
:param target: dict to update
:param reserved: dict or list with reserved keys to skip
:param rename_fields: an optional dict, used to rename field names in the output.
        Rename levelname to log.level: {'levelname': 'log.level'}

startswith_)__dict__itemshasattrr,   get)r&   r'   r(   r)   keyvalues         A/venv/lib/python3.13/site-packages/pythonjsonlogger/jsonlogger.pymerge_record_extrar5      sd     oo++-
S,//,,16=$$S-. . M    c                   2   ^  \ rS rSrSrU 4S jrS rSrU =r$ )JsonEncoder6   z4
A custom encoder extending the default JSONEncoder
c                   > [        U[        [        [        45      (       a  U R	                  U5      $ [        U5      (       a3  SR                  [        R                  " U5      5      R                  5       $ [        U5      [        :X  d(  [        U[        5      (       d  [        U5      [        :X  a  [        U5      $  [        [        U ]?  U5      $ ! [          a      [        U5      s $ ! [         a      g f = ff = f)N )
isinstancer   r   r   format_datetime_objr   join	traceback	format_tbstriptype	Exceptionstrsuperr8   default	TypeError)selfobj	__class__s     r4   rF   JsonEncoder.default;   s    cD(D122++C00779..s34::<<#Y)#c9--9$s8O	d3C88 	3x 		s0   =C 
C:
C(%C:(
C62C:5C66C:c                 "    UR                  5       $ N)	isoformat)rH   rI   s     r4   r=   JsonEncoder.format_datetime_objQ   s    }}r6    )	__name__
__module____qualname____firstlineno____doc__rF   r=   __static_attributes____classcell__)rJ   s   @r4   r8   r8   6   s    , r6   r8   c                       \ rS rSrSrS rS rS\\   4S jr	S\
\\4   S\R                  S	\
\\4   SS
4S jrS rS rS rS\
\\4   S\4S jrS\R                  S\4S jrSrg
)JsonFormatterU   z
A custom formatter to format logging records as json strings.
Extra values will be formatted as str() if not supported by
json default encoder
c                    U R                  UR                  SS5      5      U l        U R                  UR                  SS5      5      U l        U R                  UR                  S[        R
                  5      5      U l        UR                  SS5      U l        UR                  SS5      U l        UR                  SS	5      U l	        UR                  S
0 5      U l
        UR                  S0 5      U l        UR                  S[        5      n[        [        X35      5      U l        UR                  SS5      U l        ["        R$                  R&                  " U /UQ70 UD6  U R                  (       d  U R                  (       d  [(        U l        U R+                  5       U l        [        [        U R,                  U R,                  5      5      U l        U R.                  R1                  U R                  5        g)aY  
:param json_default: a function for encoding non-standard objects
    as outlined in https://docs.python.org/3/library/json.html
:param json_encoder: optional custom encoder
:param json_serializer: a :meth:`json.dumps`-compatible callable
    that will be used to serialize the log record.
:param json_indent: an optional :meth:`json.dumps`-compatible numeric value
    that will be used to customize the indent of the output json.
:param prefix: an optional string prefix added at the beginning of
    the formatted string
:param rename_fields: an optional dict, used to rename field names in the output.
    Rename message to @message: {'message': '@message'}
:param static_fields: an optional dict, used to add fields with static values to all logs
:param json_indent: indent parameter for json.dumps
:param json_ensure_ascii: ensure_ascii parameter for json.dumps
:param reserved_attrs: an optional list of fields that will be skipped when
    outputting json log record. Defaults to all log record attributes:
    http://docs.python.org/library/logging.html#logrecord-attributes
:param timestamp: an optional string/boolean field to add a timestamp when
    outputting the json log record. If string is passed, timestamp will be added
    to log record using string as key. If True boolean is passed, timestamp key
    will be "timestamp". Defaults to False/off.
json_defaultNjson_encoderjson_serializerjson_indentjson_ensure_asciiTprefixr;   r)   static_fieldsreserved_attrs	timestampF)
_str_to_fnpopr\   r]   jsondumpsr^   r_   r`   ra   r)   rb   r%   dictziprc   rd   logging	Formatter__init__r8   parse_required_fields_skip_fieldsupdate)rH   r   kwargsrc   s       r4   rm   JsonFormatter.__init__\   sw   0 !OOFJJ~t,LM OOFJJ~t,LM#vzz:KTZZ/XY!::mT:!',?!Fjj2.#ZZ<#ZZ<$4nE"3~#FGK7 	""49$9&9  ):): +D $

 T%:%:%)%:%:"< =  !4!45r6   c                     [        U[        5      (       d  U$ UR                  S5      u  p#n[        R                  " U5      n[        XT5      $ )z
If the argument is not a string, return whatever was passed in.
Parses a string such as package.module.function, imports the module
and returns the function.

:param fn_as_str: The string to parse. If not a string, return it.
.)r<   rD   
rpartition	importlibimport_modulegetattr)rH   	fn_as_strpathr-   functionr   s         r4   re   JsonFormatter._str_to_fn   sG     )S))%005((.v((r6   r*   c                 h   [        U R                  [        R                  5      (       a&  [        R
                  " S[        R                  5      nO[        U R                  [        R                  5      (       a&  [        R
                  " S[        R                  5      nOg[        U R                  [        R                  5      (       a&  [        R
                  " S[        R                  5      nO[        SU R                  -  5      eU R                  (       a  UR                  U R                  5      $ / $ )z
Parses format string looking for substitutions

This method is responsible for returning a list of fields (as strings)
to include in all log messages.
z\$\{(.+?)\}z	\{(.+?)\}z
%\((.+?)\)zInvalid format: %s)r<   _stylerk   StringTemplateStylerecompile
IGNORECASEStrFormatStylePercentStyle
ValueError_fmtfindall)rH   formatter_style_patterns     r4   rn   JsonFormatter.parse   s     dkk7#>#>??&(jj&O#W%;%;<<&(jjr}}&M# W%9%9::&(jj&N#1DII=>>99*22499==Ir6   
log_recordr&   message_dictNc                    U R                    H   nUR                  R                  U5      X'   M"     UR                  U R                  5        UR                  U5        [        X!U R                  U R                  S9  U R                  (       aZ  [        U R                  5      [        :X  a  U R                  OSn[        R                  " UR                  [        R                  S9X'   U R!                  U5        g)zC
Override this method to implement custom logic for adding fields.
)r(   r)   rd   )tzN)ro   r.   r1   rq   rb   r5   rp   r)   rd   rB   rD   r   fromtimestampr   r   utc_perform_rename_log_fields)rH   r   r&   r   fieldr2   s         r4   
add_fieldsJsonFormatter.add_fields   s     **E & 3 3E :J + 	$,,-,'68I8IY]YkYkl>>$($8C$?$..[C&44V^^UJO''
3r6   c                 Z    U R                   R                  5        H  u  p#X   X'   X	 M     g rM   )r)   r/   )rH   r   old_field_namenew_field_names       r4   r   (JsonFormatter._perform_rename_log_fields   s0    .2.@.@.F.F.H*N)3)CJ&* /Ir6   c                     U$ )zT
Override this method to implement custom logic
on the possibly ordered dictionary.
rP   rH   r   s     r4   process_log_record JsonFormatter.process_log_record   s
    
 r6   c                 x    U R                  UU R                  U R                  U R                  U R                  S9$ )z(Returns a json string of the log record.)rF   clsindentensure_ascii)r^   r\   r]   r_   r`   r   s     r4   jsonify_log_record JsonFormatter.jsonify_log_record   sB    ##J,0,=,=(,(9(9+/+;+;151G1G	 $ I 	Ir6   c                 D    U R                   < U R                  U5      < 3$ )z3Returns the final representation of the log record.)ra   r   r   s     r4   serialize_log_record"JsonFormatter.serialize_log_record   s    d&=&=j&IJJr6   c                    0 n[        UR                  [        5      (       a  UR                  nSUl        OUR	                  5       Ul        SU R
                  ;   a   U R                  XR                  5      Ul        UR                  (       a4  UR                  S5      (       d  U R                  UR                  5      US'   UR                  S5      (       d   UR                  (       a  UR                  US'   UR                  (       a4  UR                  S5      (       d  U R                  UR                  5      US'   [        5       nU R!                  X1U5        U R#                  U5      nU R%                  U5      $ )z+Formats a log record and serializes to jsonr;   r   r   r"   )r<   r   ri   r   
getMessagero   
formatTimedatefmtr   r   r1   formatExceptionr   r"   formatStackr   r   r   r   )rH   r&   r   r   s       r4   formatJsonFormatter.format   s   ') fjj$''!::LFN#..0FN---!__V\\BFN ??<#3#3J#?#?'+';';FOO'LL$
++'-L$ \%5%5l%C%C)-)9)9&:K:K)LL&%0]

L9,,Z8
((44r6   )ro   rp   r\   r]   r`   r_   r^   ra   r)   rc   rb   rd   )rQ   rR   rS   rT   rU   rm   re   r   rD   rn   r   r   rk   	LogRecordr   r   r   r   r   r   rV   rP   r6   r4   rY   rY   U   s    ,6\)tCy .4T#s(^ 4W=N=N 4^bcfhkck^l 4qu 4"+
IKtCH~ K# K5W.. 53 5r6   rY   rM   )rU   rk   rg   r   r   r   r   r   r?   rw   typingr   r   r	   r
   r   r   inspectr   collectionsr   r%   rD   __annotations__r   r5   JSONEncoderr8   rl   rY   rP   r6   r4   <module>r      s      	 3 3   : :  ##Lc3h L .2	 D$J DSM*	
 
4$"" >a5G%% a5r6   