
    iv                     X    d Z ddlZddlZddlmZmZ  G d dej
                        Zd Zy)z&Structured JSON logging configuration.    N)datetimetimezonec                       e Zd ZdZd Zy)JSONFormatterzDFormat log records as single-line JSON for structured log ingestion.c                    t        j                  t        j                        j	                         |j
                  |j                  |j                         d}t        |d      r|j                  |d<   t        |d      r|j                  |d<   |j                  r| j                  |j                        |d<   t        j                  |d      S )N)	timestamplevelloggermessage
project_id
episode_id	exceptionF)ensure_ascii)r   nowr   utc	isoformat	levelnamename
getMessagehasattrr   r   exc_infoformatExceptionjsondumps)selfrecordlog_datas      M/Users/manta/Documents/Projects/TheRoad-I1/backend/app/core/logging_config.pyformatzJSONFormatter.format   s    !hll3==?%%kk((*	
 6<(%+%6%6H\"6<(%+%6%6H\"??$($8$8$IH[!zz(77    N)__name__
__module____qualname____doc__r    r    r   r   r      s
    N8r    r   c                      t        j                         } | j                  t                      | gt         j                  _        t         j                  j                  t         j                         y)zwConfigure root logger with JSON formatter.

    Call once at application startup, before any other initialization.
    N)loggingStreamHandlersetFormatterr   roothandlerssetLevelINFO)handlers    r   setup_loggingr/      sF    
 ##%G)$IGLLLL',,'r    )r$   r'   r   r   r   	Formatterr   r/   r%   r    r   <module>r1      s(    ,   '8G%% 8&(r    