o
    wOi                     @   s~   d Z ddlZddlmZ ddlmZmZmZmZ da	dde
dejfd	d
Zddede
ddfddZddede
ddfddZdS )a+  
Module contains events processing mechanisms that are integrated with the standard python logging.

Example of usage:

::

  from torchelastic import events
  event = Event(name="test_event", source=EventSource.WORKER, metadata={...})
  events.get_events_logger(destination="default").info(event)

    N)get_logging_handler   )EventEventSourceTsmEventEventMetadataValuenulldestinationreturnc                 C   s@   t rt S t| }td|  a t tj dt _t | t S )aF  
    Constructs python logger based on the destination type or extends if provided.
    Available destination could be found in ``handlers.py`` file.
    The constructed logger does not propagate messages to the upper level loggers,
    e.g. root logger. This makes sure that a single event can be processed once.

    Args:
        destination: The string representation of the event handler.
            Available handlers found in ``handlers`` module
        logger: Logger to be extended with the events handler. Method constructs
            a new logger if None provided.
    ztorchelastic-events-F)_events_loggerr   logging	getLoggersetLevelDEBUG	propagate
addHandler)r	   logging_handler r   P/home/ubuntu/.local/lib/python3.10/site-packages/torchelastic/events/__init__.py_get_or_create_logger   s   
r   consoleeventc                 C      t ||   d S Nr   info	serializer   r	   r   r   r   record8      r   c                 C   r   r   r   r   r   r   r   
record_tsm<   r   r    )r   )r   )__doc__r   torchelastic.events.handlersr   apir   r   r   r   r   strLoggerr   r   r    r   r   r   r   <module>   s   