
    Mi|                     X   % S SK r S SKrS SKrS SKrS SKJr  S SKJr  Sr\SL a  \R                  " S5        \" \R                  " SS5      5      r
\R                  " SS	5      r\" \\R                  5       5      r\\S
'   \R"                  " 5       r\R'                  \5         " S S\5      rS r\
(       a$  \R-                  \" 5       5        \" \" 5       5        O"\R
                  " SSS9r\R-                  \5        \R0                  " S5      r\R0                  " S5      r\R0                  " S5      r\R9                  \5        \R9                  \5        \R9                  \5        S r\" 5         \R0                  " 5       \\\/rS\R>                  4S jr S r!S r"S r#S r$S r%S\4S jr&g)    N)datetime)	FormatterFTze`litellm.set_verbose` is deprecated. Please set `os.environ['LITELLM_LOG'] = 'DEBUG'` for debug logs.	JSON_LOGSLITELLM_LOGDEBUGnumeric_levelc                   8   ^  \ rS rSrU 4S jrSS jrS rSrU =r$ )JsonFormatter   c                 *   > [         [        U ]  5         g N)superr
   __init__)self	__class__s    j/var/www/eduai.edurigo.com/storigo/production/storigo_env/lib/python3.13/site-packages/litellm/_logging.pyr   JsonFormatter.__init__   s    mT+-    c                 b    [         R                  " UR                  5      nUR                  5       $ r   )r   fromtimestampcreated	isoformat)r   recorddatefmtdts       r   
formatTimeJsonFormatter.formatTime   s"    ##FNN3||~r   c                     UR                  5       UR                  U R                  U5      S.nUR                  (       a  U R	                  UR                  5      US'   [
        R                  " U5      $ )N)messagelevel	timestamp
stacktrace)
getMessage	levelnamer   exc_infoformatExceptionjsondumps)r   r   json_records      r   formatJsonFormatter.format   s[    ((*%%0
 ??(,(<(<V__(MK%zz+&&r    r   )	__name__
__module____qualname____firstlineno__r   r   r*   __static_attributes____classcell__)r   s   @r   r
   r
      s    .

' 
'r   r
   c                    ^ [         R                  " 5       mTR                  U 5        U4S jnU[        l         SS KnU4S jnUR                  5       R                  U5        g ! [         a     g f = f)Nc                    > [         R                  " S[         R                  SS[        U5      SXU4S9nTR	                  U5        g )NLiteLLM r   r,   namer    pathnamelinenomsgargsr%   )logging	LogRecordERRORstrhandle)exc_type	exc_valueexc_tracebackr   error_handlers       r   json_excepthook7_setup_json_exception_handlers.<locals>.json_excepthook3   sE    ""--I=9
 	V$r   r   c           
         > UR                  S5      nU(       aC  [        R                  " S[        R                  SS[	        U5      SS S9nTR                  U5        g U R                  U5        g )N	exceptionr5   r6   r   r,   r7   )getr=   r>   r?   r@   rA   default_exception_handler)loopcontextrI   r   rE   s       r   async_json_exception_handlerD_setup_json_exception_handlers.<locals>.async_json_exception_handlerE   s_    K0I **"!--I! $$V,..w7r   )	r=   StreamHandlersetFormattersys
excepthookasyncioget_event_loopset_exception_handler	Exception)	formatterrF   rT   rN   rE   s       @r   _setup_json_exception_handlersrY   -   sf    ))+My)
% %CN	8  	 667ST s   )A$ $
A10A1zT[92m%(asctime)s - %(name)s:%(levelname)s[0m: %(filename)s:%(lineno)s - %(message)sz%H:%M:%S)r   zLiteLLM ProxyzLiteLLM Routerr5   c                  B   [         R                  " S5      n U R                  [         R                  5        [         R                  " S5      nUR                  [         R                  5        [         R                  " S5      nUR                  [         R                  5        g)z$Suppress noisy loggers at INFO levelhttpxzapscheduler.executors.defaultzapscheduler.schedulerN)r=   	getLoggersetLevelWARNING)httpx_loggerapscheduler_executors_loggerapscheduler_scheduler_loggers      r   _suppress_loggersrb   p   sp     $$W-L'//* $+#4#45T#U  ))'//:#*#4#45L#M  ))'//:r   handlerc                     [          H5  nUR                  R                  5         UR                  U 5        SUl        M7     g)z
Initialize all loggers with a handler

- Adds a handler to each logger
- Prevents bubbling to parent/root (critical to prevent duplicate JSON logs)
FN)ALL_LOGGERShandlersclear
addHandler	propagate)rc   lgs     r    _initialize_loggers_with_handlerrk      s1     

g r   c                      [         R                  " 5       n U R                  [        5       5        [	        U 5        [        [        5       5        g)z>
Turn on JSON logging

- Adds a JSON formatter to all loggers
N)r=   rP   rQ   r
   rk   rY   )rc   s    r   _turn_on_jsonrm      s4     ##%G)$W-"=?3r   c                      [         R                  [        R                  S9  [        R                  [        R                  S9  [
        R                  [        R                  S9  g )N)r    )verbose_loggerr]   r=   r   verbose_router_loggerverbose_proxy_loggerr,   r   r   _turn_on_debugrr      sA    '--0"""7!!!6r   c                  F    S[         l        S[        l        S[        l        g )NTro   disabledrp   rq   r,   r   r   _disable_debuggingrv      s    "N%)"$(!r   c                  F    S[         l        S[        l        S[        l        g )NFrt   r,   r   r   _enable_debuggingrx      s    #N%*"$)!r   c                 T     [         (       a  [        U 5        g g ! [         a     g f = fr   )set_verboseprintrW   )print_statements    r   print_verboser}      s+    ;/"  s    
''returnc                  f    [         R                  [        R                  5      =(       d    [        SL $ )z!
Returns True if debugging is on
T)ro   isEnabledForr=   r   rz   r,   r   r   _is_debugging_onr      s#     &&w}}5L9LLr   )'r'   r=   osrR   r   r   rz   warningboolgetenv	json_logs	log_levelgetattrupperr   r@   __annotations__rP   rc   r]   r
   rY   rQ   rX   r\   rq   rp   ro   rh   rb   re   Handlerrk   rm   rr   rv   rx   r}   r   r,   r   r   <module>r      s     	 
  $OOo ;./	IImW-	Wioo&78s 8



!    'I '.*\ )"=?3!!dI
 #((9 ))*:; ""9-      )    (   ' "
;   	
goo 

47)*M$ Mr   