o
    0 i                     @  s   d Z ddlmZ ddlZddlZddlmZmZmZm	Z	 ddl
Z
ddlmZ ddlmZ G dd	 d	ejZG d
d dejZdddZdS )zJSON formatter using the standard library's `json` for encoding.

Module contains the `JsonFormatter` and a custom `JsonEncoder` which supports a greater
variety of types.
    )annotationsN)AnyCallableOptionalUnion   )core)defaultsc                      s,   e Zd ZdZd fddZdd	d
Z  ZS )JsonEncoderzkA custom encoder extending [json.JSONEncoder](https://docs.python.org/3/library/json.html#json.JSONEncoder)or   returnc                   s   t |r
| |S t |rt |S t |rt |S t |r(t |S t 	|r2t 
|S t |r<t |S t |rFt |S zt |W S  ty[   t | Y S w )N)dZuse_datetime_anyformat_datetime_objZuse_exception_defaultZexception_defaultZuse_traceback_defaultZtraceback_defaultZuse_enum_defaultZenum_defaultZuse_bytes_defaultZbytes_defaultZuse_dataclass_defaultZdataclass_defaultZuse_type_defaultZtype_defaultsuperdefault	TypeErrorZunknown_defaultselfr   	__class__ a/home/app/PaddleOCR-VL-test/.venv_paddleocr/lib/python3.10/site-packages/pythonjsonlogger/json.pyr      s&   













zJsonEncoder.default1datetime.time | datetime.date | datetime.datetimestrc                 C  s
   t |S )zFormat datetime objects found in `self.default`

        This allows subclasses to change the datetime format without understanding the
        internals of the default method.
        )r   Zdatetime_anyr   r   r   r   r   7   s   
zJsonEncoder.format_datetime_obj)r   r   r   r   )r   r   r   r   )__name__
__module____qualname____doc__r   r   __classcell__r   r   r   r   r
      s    r
   c                      s<   e Zd ZdZddejdddd fddZdddZ  ZS )JsonFormatterznJSON formatter using the standard library's [`json`](https://docs.python.org/3/library/json.html) for encodingNT)json_defaultjson_encoderjson_serializerjson_indentjson_ensure_asciir    Optional[Callable]r!   r"   r   r#   Optional[Union[int, str]]r$   boolr   Nonec                  sF   t  j|i | || _|| _|| _|| _|| _| js!| js!t| _dS )a  
        Args:
            args: see [BaseJsonFormatter][pythonjsonlogger.core.BaseJsonFormatter]
            json_default: a function for encoding non-standard objects
            json_encoder: custom JSON encoder
            json_serializer: a [`json.dumps`](https://docs.python.org/3/library/json.html#json.dumps)-compatible callable
                that will be used to serialize the log record.
            json_indent: indent parameter for the `json_serializer`
            json_ensure_ascii: `ensure_ascii` parameter for the `json_serializer`
            kwargs: see [BaseJsonFormatter][pythonjsonlogger.core.BaseJsonFormatter]
        N)r   __init__r    r!   r"   r#   r$   r
   )r   r    r!   r"   r#   r$   argskwargsr   r   r   r)   C   s   zJsonFormatter.__init__log_datacore.LogDatar   c                 C  s   | j || j| j| j| jdS )z&Returns a json string of the log data.)r   clsindentensure_ascii)r"   r    r!   r#   r$   )r   r,   r   r   r   jsonify_log_recordc   s   z JsonFormatter.jsonify_log_record)r    r%   r!   r%   r"   r   r#   r&   r$   r'   r   r(   )r,   r-   r   r   )	r   r   r   r   jsondumpsr)   r1   r   r   r   r   r   r   @   s     r   namer   c                 C  s.   | dkrt dt tjS tdt d|  )NRESERVED_ATTRSz6RESERVED_ATTRS has been moved to pythonjsonlogger.corezmodule z has no attribute )warningswarnDeprecationWarningr   r5   AttributeErrorr   )r4   r   r   r   __getattr__p   s   r:   )r4   r   )r   
__future__r   datetimer2   typingr   r   r   r   r6    r   r	   r   JSONEncoderr
   ZBaseJsonFormatterr   r:   r   r   r   r   <module>   s    	'0