
    ^ht>                    &   % S r SSKJr  SSKJrJr  SSKrSSKrSSKrSSKJ	r	J
r
JrJrJrJrJr  \R                   S:  a  SSKJr  OSSKJr  / SQrS	\S
'    \R                   S:  a!  \R+                  S5        \R-                  5         \R.                  " S\R0                  5      r\R.                  " S\R0                  5      r\R.                  " S\R0                  5      r\\\4   rS\S'     S         SS jjr " S S\R>                  5      r g)z-Core functionality shared by all JSON loggers    )annotations)datetimetimezoneN)OptionalUnionListDict	ContainerAnySequence)   
   )	TypeAlias)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	List[str]RESERVED_ATTRS)r      taskNamez\$\{(.+?)\}z	\{(.+?)\}z
%\((.+?)\)r   LogDatac                    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$ )a  
Merges extra attributes from LogRecord object into target dictionary

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

*Changed in 3.1*: `reserved` is now `Container[str]`.

startswith_)__dict__itemshasattrr,   get)recordtargetreservedrename_fieldskeyvalues         O/home/james-whalen/.local/lib/python3.13/site-packages/pythonjsonlogger/core.pymerge_record_extrar9   S   sc    $ oo++-
\(B(Bs~~VYGZGZ27=$$S./ . M    c                    ^  \ rS rSr% SrS\S'       SSSSSSSSSSS.	                           SS	 jjjrSS
 jrSS jrSS jr	        SS jr
SS jrSS jrSS jrSU 4S jjrSU 4S jjrSrU =r$ )BaseJsonFormatterp   zBase class for all formatters

Must not be used directly.

*New in 3.1*

*Changed in 3.2*: `defaults` argument is no longer ignored.

*Added in 3.3*: `exc_info_as_array` and `stack_info_as_array` options are added.
z Union[logging.PercentStyle, str]_styleN F)	prefixr5   rename_fields_keep_missingstatic_fieldsreserved_attrs	timestampdefaultsexc_info_as_arraystack_info_as_arrayc       	           Ub  [        U[        5      (       a  U[        R                  ;   aK  [        R                  U   S   " U5      nU(       a  UR	                  5         Xl        UR                  U l        O%US:X  d  U(       d  X0l        Xl        O[        S5      eU R                  5       U l	        O<[        U[        5      (       a'  SU l        [        U5      U l        [        U5      U l	        X l        XPl        Ub  U Vs0 s H  oXo   _M	     snO0 U l        Ub  U Vs0 s H  oX   _M	     snO0 U l        Xpl        [#        U	b  U	O[$        5      U l        Xl        [#        U R                  5      U l        U R*                  R-                  U R&                  5        Ub  UO0 U l        Xl        Xl        gs  snf s  snf )as	  
Args:
    fmt: String format or `Sequence` of field names of fields to log.
    datefmt: format to use when formatting `asctime` field
    style: how to extract log fields from `fmt`. Ignored if `fmt` is a `Sequence[str]`.
    validate: validate `fmt` against style, if implementing a custom `style` you
        must set this to `False`. Ignored if `fmt` is a `Sequence[str]`.
    defaults: a dictionary containing default fields that are added before all other fields and
        may be overridden. The supplied fields are still subject to `rename_fields`.
    prefix: an optional string prefix added at the beginning of
        the formatted string
    rename_fields: an optional dict, used to rename field names in the output.
        Rename `message` to `@message`: `{'message': '@message'}`
    rename_fields_keep_missing: When renaming fields, include missing fields in the output.
    static_fields: an optional dict, used to add fields with static values to all logs
    reserved_attrs: an optional list of fields that will be skipped when
        outputting json log record. Defaults to [all log record attributes][pythonjsonlogger.core.RESERVED_ATTRS].
    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.
    exc_info_as_array: break the exc_info into a list of lines based on line breaks.
    stack_info_as_array: break the stack_info into a list of lines based on line breaks.

*Changed in 3.1*:

- you can now use custom values for style by setting validate to `False`.
  The value is stored in `self._style` as a string. The `parse` method will need to be
  overridden in order to support the new style.
- Renaming fields now preserves the order that fields were added in and avoids adding
  missing fields. The original behaviour, missing fields have a value of `None`, is still
  available by setting `rename_fields_keep_missing` to `True`.

*Added in 4.0*:

- `fmt` now supports comma seperated lists (`style=","`). Note that this style is specific
  to `python-json-logger` and thus care should be taken to not to pass this format to other
  logging Formatter implementations.
- `fmt` now supports sequences of strings (e.g. lists and tuples) of field names.
Nr   ,zStyle must be one of: '%{$,'__sequence__)
isinstancestrlogging_STYLESvalidater>   _fmt
ValueErrorparse_required_fieldsr   listdatefmtr@   r5   rB   rA   setr'   rC   rD   _skip_fieldsupdaterE   rF   rG   )selffmtrU   stylerO   r@   r5   rA   rB   rC   rD   rE   rF   rG   r>   r6   s                   r8   __init__BaseJsonFormatter.__init__   s   x ;*S#..' /237OO%$"KK	#X#	 !!?@@$(JJLD! X&&(DKCDI$(ID!  CPB[>-$$>ac 	 CPB[>-$$>ac 	 +E'!N4N.Tbc" 5 56  !4!45$,$8b!2#6  ? ?s   F6!F;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'   0 nU R                  X1U5        U R!                  U5      nU R#                  U5      $ )zTFormats a log record and serializes to json

Args:
    record: the record to format
r?   r   r   r#   )rK   r   dictr   
getMessagerS   
formatTimerU   r   r   r1   formatExceptionr   r#   formatStack
add_fieldsprocess_log_recordserialize_log_record)rY   r2   message_dictlog_datas       r8   formatBaseJsonFormatter.format   s!    (* fjj$''!::LFN#..0FN ---!__V\\BFN ??<#3#3J#?#?'+';';FOO'LL$
++'-L$ \%5%5l%C%C)-)9)9&:K:K)LL&,7**84((22r:   c                   U R                   c  / $ [        U R                  [        5      (       a  U R                  S:X  a  [	        S5      eU R                  S:X  aP  U R                   R                  S5       Vs/ s H)  oR                  5       (       d  M  UR                  5       PM+     sn$ [        SU R                  < S35      e[        U R                  [        R                  5      (       a  [        nOz[        U R                  [        R                  5      (       a  [        nOJ[        U R                  [        R                  5      (       a  [        nO[        SU R                  < S35      eUR                  U R                   5      $ s  snf )a  Parses format string looking for substitutions

This method is responsible for returning a list of fields (as strings)
to include in all log messages.

You can support custom styles by overriding this method.

Returns:
    list of fields to be extracted and serialized
rJ   z5Must not call parse when fmt is a sequence of stringsrI   zStyle z is not supported)rP   rK   r>   rL   RuntimeErrorsplitstriprQ   rM   StringTemplateStyleSTYLE_STRING_TEMPLATE_REGEXStrFormatStyleSTYLE_STRING_FORMAT_REGEXPercentStyleSTYLE_PERCENT_REGEXfindall)rY   fieldformatter_style_patterns      r8   rR   BaseJsonFormatter.parse  s"    99Idkk3''{{n,"#Z[[{{c!3799??33GY3G%;;=3GYYvdkk_4EFGGdkk7#>#>??&A#W%;%;<<&?#W%9%9:: ':# vdkk_4EFGG&..tyy99% Zs   7F	F	c                >    U R                   U R                  U5      -   $ )zReturns the final representation of the data to be logged

Args:
    log_data: the data

*Changed in 4.0*: `log_record` renamed to `log_data`
)r@   jsonify_log_recordrY   rh   s     r8   rf   &BaseJsonFormatter.serialize_log_record>  s     {{T44X>>>r:   c                   U R                    H#  nU R                   U   XR                  U5      '   M%     U R                   H/  nUR                  R	                  U5      XR                  U5      '   M1     U R
                  U4 H/  nUR                  5        H  u  pgXqU R                  U5      '   M     M1     [        UUU R                  U R                  S9  U R                  (       ak  [        U R                  [        5      (       a  U R                  OSn[        R                  " UR                  [         R"                  S9XR                  U5      '   U R$                  (       a,  U R                  R'                  5        H  nXA;  d  M
  SX'   M     g)a  Extract fields from a LogRecord for logging

This method can be overridden to implement custom logic for adding fields.

Args:
    log_data: data that will be logged
    record: the record to extract data from
    message_dict: dictionary that was logged instead of a message. e.g
        `logger.info({"is_this_message_dict": True})`

*Changed in 4.0*: `log_record` renamed to `log_data`
)r4   r5   rD   )tzN)rE   _get_renamerS   r.   r1   rB   r/   r9   rW   r5   rD   rK   rL   r   fromtimestampr   r   utcrA   values)rY   rh   r2   rg   rv   	data_dictr6   r7   s           r8   rd   BaseJsonFormatter.add_fieldsH  sF   $ ]]E04e0DH%%e,- # **E060C0CE0JH%%e,- + ,,l;I'oo/
27))#./ 0 < 	&&,,		
 >>$.t~~s$C$C$..C.6.D.D8<</H%%c*+ **++224(&*HO 5 	r:   c                8    U R                   R                  X5      $ N)r5   r1   )rY   r6   s     r8   r   BaseJsonFormatter._get_renamew  s    !!%%c//r:   c                    [        5       e)zConvert the log data into a JSON string.

Child classes MUST override this method.

Args:
    log_data: the data to serialize

*Changed in 4.0*: `log_record` renamed to `log_data`
)NotImplementedErrorr{   s     r8   rz   $BaseJsonFormatter.jsonify_log_record|  s     "##r:   c                    U$ )zCustom processing of the data to be logged.

Child classes can override this method to alter the log record before it
is serialized.

Args:
    log_data: incoming data

*Changed in 4.0*: `log_record` renamed to `log_data`
 r{   s     r8   re   $BaseJsonFormatter.process_log_record  s	     r:   c                h   > [         TU ]  U5      nU R                  (       a  UR                  5       $ U$ )zFormat and return the specified exception information.

If exc_info_as_array is set to True, This method returns an array of strings.
)superrb   rF   
splitlines)rY   eiexception_info_str	__class__s      r8   rb   !BaseJsonFormatter.formatException  s3    
 #W4R8262H2H!,,.`N``r:   c                h   > [         TU ]  U5      nU R                  (       a  UR                  5       $ U$ )zFormat and return the specified stack information.

If stack_info_as_array is set to True, This method returns an array of strings.
)r   rc   rG   r   )rY   r#   stack_info_strr   s      r8   rc   BaseJsonFormatter.formatStack  s0    
 ,Z8.2.F.F~((*ZNZr:   )rP   rS   rW   r>   rU   rE   rF   r@   r5   rA   rC   rG   rB   rD   )NN%T)rZ   z#Optional[Union[str, Sequence[str]]]rU   zOptional[str]r[   rL   rO   boolr@   rL   r5   Optional[Dict[str, str]]rA   r   rB   Optional[Dict[str, Any]]rC   zOptional[Sequence[str]]rD   zUnion[bool, str]rE   r   rF   r   rG   r   returnNone)r2   logging.LogRecordr   rL   )r   r&   )rh   r*   r   rL   )rh   Dict[str, Any]r2   r   rg   r   r   r   )r6   rL   r   rL   )rh   r*   r   r*   )r   zUnion[str, list[str]])__name__
__module____qualname____firstlineno____doc____annotations__r\   ri   rR   rf   rd   r   rz   re   rb   rc   __static_attributes____classcell__)r   s   @r8   r<   r<   p   s>   	 -, 48!%m 26+02626&+-1"'$)m0m m 	m
 m m 0m %)m 0m 0m $m +m  m "m  
!m^#3N%:N?- - "- %	-
 
-^0

$a[ [r:   r<   r   )
r2   r   r3   r	   r4   zContainer[str]r5   r   r   r	   )!r   
__future__r   r   r   rM   resystypingr   r   r   r	   r
   r   r   version_infor   typing_extensionsr'   r   appendsortcompile
IGNORECASErp   rr   rt   rL   r*   r9   	Formatterr<   r   r:   r8   <module>r      s   3
 # (  	 
 H H Hw +	 0	 w*% !jjG JJ|R]]C jj>  #s(^ # /3	  ,	
 
:s[)) s[r:   