s( d Z g dZddlZddlZddlZddlZddlZddlZddlm Z ddl
mZmZ ddl
Z
e ddddd Z G d
dej Z G d d
ej Z ej d Zde_ ee Z ej Ze e ddddeeeeej f deddfdZ G d dej Z dS )uo
Logging utilities for dill.
The 'logger' object is dill's top-level logger.
The 'adapter' object wraps the logger and implements a 'trace()' method that
generates a detailed tree-style trace for the pickling call at log level INFO.
The 'trace()' function sets and resets dill's logger log level, enabling and
disabling the pickling trace.
The trace shows a tree structure depicting the depth of each object serialized
*with dill save functions*, but not the ones that use save functions from
'pickle._Pickler.dispatch'. If the information is available, it also displays
the size in bytes that the object contributed to the pickle stream (including
its child objects). Sample trace output:
>>> import dill, dill.tests
>>> dill.detect.trace(True)
>>> dill.dump_session(main=dill.tests)
┬ M1:
├┬ F2:
│└ # F2 [32 B]
├┬ D2:
│├┬ T4:
││└ # T4 [35 B]
│├┬ D2:
││├┬ T4:
│││└ # T4 [50 B]
││├┬ D2:
│││└ # D2 [84 B]
││└ # D2 [413 B]
│└ # D2 [763 B]
└ # M1 [813 B]
)adapterloggertrace N)partial)TextIOUnion|+`) │u ├ ┬ └c 6 e Zd ZdZd Zd Zd Zd Zd Zd Z dS ) TraceAdaptera
Tracks object tree depth and calculates pickled object size.
A single instance of this wraps the module's logger, as the logging API
doesn't allow setting it directly with a custom Logger subclass. The added
'trace()' method receives a pickle instance as the first argument and
creates extra values to be added in the LogRecord from it, then calls
'info()'.
Usage of logger with 'trace()' method:
>>> from dill.logger import adapter as logger #NOTE: not dill.logger.logger
>>> ...
>>> def save_atype(pickler, obj):
>>> logger.trace(pickler, "Message with %s and %r etc. placeholders", 'text', obj)
>>> ...
c || _ d S N)r )selfr s ]/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/dill/logger.py__init__zTraceAdapter.__init__t s
c t d| }| | | j | d S )Nz%(prefix)s%(message)s%(suffix)shandler)TraceFormattersetFormatterr
addHandler)r r formatters r r zTraceAdapter.addHandlerv sE "#DgVVV Y'''w'''''r c : | j | d S r )r
removeHandler)r r s r r zTraceAdapter.removeHandlerz s !!'*****r c
||fS r )r msgkwargss r processzTraceAdapter.process| s F{r c t j |d sd S | t j rd|_ g |_ d S d |_ d S )NF)child )dill_dillis_dillisEnabledForloggingINFO_trace_depth_size_stack)r picklers r trace_setupzTraceAdapter.trace_setup s` z!!'!77 FW\** (#$G "$G#'G r c t |d st j |g|R i | d S |j d S | di }| d }d } |j }|j j } || z
}n"# t $ r |t | z
}Y nw xY wn# t t f$ r Y nw xY w|>|s|j
| n!||j
z }||d<