+
    i1                     n   ^ RI t^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RIH
t
 ^ RIHt ^ RIHt Rt^#t]P"                  ^,
          t ! R R]P&                  4      t]P"                  R3R ltR	 tR
 R ltRR lt ! R R]P2                  4      tR tR t ! R R]P:                  4      tR tR# )    N)defaultdict)suppress)DefaultDictz6%(asctime)s - %(filename)s[%(levelname)s]: %(message)sc                   0   a  ] tR t^t o RtR tR tRtV tR# )CustomLoggerTypezA hack to get mypy to stop complaining about custom logging methods.

When using deprecated or trace logging, rather than:
    LOG = logging.getLogger(__name__)
Instead do:
    LOG = cast(CustomLoggerType, logging.getLogger(__name__))
c                    R # N selfargskwargss   &*,7/usr/lib/python3/dist-packages/cloudinit/log/loggers.pytraceCustomLoggerType.trace&           c                    R # r	   r
   r   s   &*,r   
deprecatedCustomLoggerType.deprecated)   r   r   r
   N)	__name__
__module____qualname____firstlineno____doc__r   r   __static_attributes____classdictcell____classdict__s   @r   r   r      s      r   r   c                 H   T;'       g    \         P                  ! \        4      p\         P                  ! 4       p\         P                  ! \
        P                  4      pVP                  V4       VP                  V 4       VP                  V4       VP                  V 4       R # r	   )
logging	FormatterDEFAULT_LOG_FORMAT	getLoggerStreamHandlersysstderrsetFormattersetLevel
addHandler)level	formatterrootconsoles   &&  r   setup_basic_loggingr/   -   sq    BBW../ABID##CJJ/G#UOOGMM%r   c                 6   V '       g   R # V P                    FU  p\        V\        P                  4      '       g   K%  \	        \
        4      ;_uu_ 4        VP                  4        R R R 4       KW  	  \        V P                  4       R #   + '       g   i     K  ; ir	   )	handlers
isinstancer!   r%   r   IOErrorflushflush_loggersparent)r-   hs   & r   r5   r5   7   s_    ]]a'//11'""	 #"  $++ #""s   BBc                    V ^8  d   QhRR/# )   returnNr
   )formats   "r   __annotate__r<   A   s     8 8d 8r   c                    R p \         P                  ! \        R4       \         P                  ! \        R4       \	        \         P
                  RV ! \        4      4       \	        \         P
                  RV ! \        4      4       R# )z:Add DEPRECATED and TRACE log levels to the logging module.c                    a  V 3R  lpV# )c                 b   < V P                  S4      '       d   V P                  ! SW3/ VB  R # R # r	   )isEnabledFor_log)r   messager   r   r+   s   &&*,r   log_at_level>define_extra_loggers.<locals>.new_logger.<locals>.log_at_levelE   s,      ''		%9&9 (r   r
   )r+   rC   s   f r   
new_logger(define_extra_loggers.<locals>.new_loggerD   s    	: r   
DEPRECATEDTRACEr   r   N)r!   addLevelNamerG   rH   setattrLogger)rE   s    r   define_extra_loggersrL   A   sS     \2(GNNL*Z*@AGNNGZ%67r   c                 J   V '       g   / p \         P                  ! 4       p\        4       pVP                  \         P                  4       . pV P                  R 4      pV'       d2   \        V\        4      '       d   VP                  \        V4      4       MRV 9   d   V R,           F  p\        V\        4      '       d   VP                  V4       K,  \        V\        P                  P                  4      '       d=   V Uu. uF  p\        V4      NK  	  ppVP                  RP                  V4      4       K  VP                  \        V4      4       K  	  ^ pV F  p\        \        4      ;_uu_ 4        V^,          pVP                  R4      '       d&   \         P"                  P%                  V4      '       g   \&        P(                  ! V4      p\         P*                  P-                  V4       VP/                  V4        RRR4        R# 	  VP/                  V4       V P                  RR4      p	\0        P2                  P5                  RV,          4       V	'       d,   \0        P2                  P5                  R4       \7        4        R# R# u upi   + '       g   i     EKI  ; i)	logcfglog_cfgs
/N	log_basicTz0WARN: no logging configured! (tried %s configs)
zSetting up basic logging...
)r!   r$   LogExporterr)   WARNgetr2   strappendcollectionsabcIterablejoinr   FileNotFoundError
startswithospathisfileioStringIOconfig
fileConfigr*   r&   r'   writer/   )
cfgroot_loggerexporterrO   log_cfga_cfgccfg_stram_triedbasic_enableds
   &         r   setup_loggingro   Q   s   ##%K}Hgll#HgghG:gs++ 	G%	s	__E%%%&EKOO$<$<>>+015a3q651		' 23E
+ % H
  '((MH &&s++w0G0G++g. NN%%g. ""8,  )(	 * 8$ GGK.MJJ;xH 

89 Q 2 )((s   ?J3AJ9AJJ"c                   `   a  ] tR t^t o ]! ]4      tV 3R lR ltR tR t	R t
V 3R ltRtV tR# )	rS   c                4   < V ^8  d   QhRS[ P                  /# )r9   record)r!   	LogRecord)r;   r   s   "r   r<   LogExporter.__annotate__   s     B B7,, Br   c                z    V P                   VP                  ,          P                  VP                  4       4       R # r	   )holder	levelnamerW   
getMessage)r   rr   s   &&r   emitLogExporter.emit   s(    F$$%,,V->->-@Ar   c                B    \         P                  ! V P                  4      # r	   )copydeepcopyrv   r   s   &r   export_logsLogExporter.export_logs   s    }}T[[))r   c                .    \        \        4      V n        R # r	   )r   listrv   r~   s   &r   
clean_logsLogExporter.clean_logs   s    !$'r   c                    R # r	   r
   r~   s   &r   r4   LogExporter.flush   r   r   c                <   < V ^8  d   Qh/ S[ S[S[3,          ;R&   # )r9   rv   )r   rV   r   )r;   r   s   "r   r<   rt      s     T	"6 r   )rv   N)r   r   r   r   r   r   rv   ry   r   r   r4   __annotate_func__r   r   r   s   @r   rS   rS      s1     %0%6FB B*(  r   rS   c                    \         P                  ! 4       p \        V P                  4      pV F4  pVP	                  4        VP                  4        V P                  V4       K6  	  V P                  \         P                  4       R# )z0Remove all current handlers and unset log level.N)	r!   r$   r   r1   r4   closeremoveHandlerr)   NOTSET)logr1   r7   s      r   reset_loggingr      sZ    



CCLL!H				!  LL r   c                    a \         P                  ! \        P                  4      o\	        SRR 4       SP                  \         P                  ! R4      4       V3R lp \	        \         P                  RV 4       R# )zIn the event that internal logging exception occurs and logging is not
possible for some reason, make a desperate final attempt to log to stderr
which may ease debugging.
handleErrorc                     R # r	   r
   )rr   s   &r   <lambda>&setup_backup_logging.<locals>.<lambda>   s    Dr   z@FALLBACK: %(asctime)s - %(filename)s[%(levelname)s]: %(message)sc                   < \        \        4      ;_uu_ 4        SP                  V4       SP                  4        RRR4       R#   + '       g   i     R# ; i)z;A closure that emits logs on stderr when other methods failN)r   r3   handler4   )r   rr   fallback_handlers   &&r   r   )setup_backup_logging.<locals>.handleError   s7    g##F+""$ s   "AA	N)r!   r%   r&   r'   rJ   r(   r"   Handler)r   r   s    @r   setup_backup_loggingr      s^    
 ,,SZZ8m-@A!!N	
% GOO]K8r   c                   6   a a ] tR t^t oRtV 3R ltRtVtV ;t# )CloudInitLogRecordzreporting the filename as __init__.py isn't very useful in logs

if the filename is __init__.py, use the parent directory as the filename
c                   < \         SV `  ! V/ VB  R V P                  8X  dN   \        P                  P                  \        P                  P                  V P                  4      4      V n        R# R# )z__init__.pyN)super__init__filenamer^   r_   basenamedirnamepathname)r   r   r   	__class__s   &*,r   r   CloudInitLogRecord.__init__   sM    $)&)DMM)GG,,RWW__T]]-KLDM *r   )r   )	r   r   r   r   r   r   r   r   __classcell__)r   r   s   @@r   r   r      s     
M Mr   r   c                 V   \         P                  \        P                  n        \        4        \        4        \        4        \        4       p V P                  \        P                  4       \        P                  ! 4       P                  V 4       \        P                  ! \        4       R# )z(Customize the root logger for cloud-initN)timegmtimer!   r"   	converterrL   r   r   rS   r)   rT   r$   r*   setLogRecordFactoryr   )handlers    r   configure_root_loggerr      sj     #'++GO mGW\\"""7+  23r   r	   ) collections.abcrX   r|   ra   r!   logging.configlogging.handlersr^   r&   r   r   
contextlibr   typingr   r#   rG   DEBUGrH   rK   r   r/   r5   rL   ro   r%   rS   r   r   rs   r   r   r
   r   r   <module>r      s      	    	 
  #  M 
w~~   &mmt 8 >B'''  !9,	M** 	M4r   