+
     ih  c                   sd    R t ^ RIt^ RIt^ RIt^ RIHt ^ RIHt  ! R R]P                  4      tR# )z!Logging setup for input-remapper.N)datetime)Dictc                   s   a a ] tR t^t oRtRV3R lV 3R llltV3R lR ltV3R lR ltV3R lR	 ltR
 t	V3R lR lt
V3R lV 3R lltRtVtV ;t# )ColorfulFormattera  Overwritten Formatter to print nicer logs.

It colors all logs from the same filename in the same color to visually group them
together. It also adds process name, process id, file, line-number and time.

If debug mode is not active, it will not do any of this.
c                s    < V ^8  d   QhRS[ /# )   
debug_mode)Zboolformat__classdict__   "D/usr/lib/python3.14/site-packages/inputremapper/logging/formatter.py__annotate__ColorfulFormatter.__annotate__&   s      
  
4  
    c           
     s  < \         SV `  4        Wn        / V n        . V n        \        ^ ^4       F  p\        ^ ^4       F  p\        ^ ^4       F  pRV,          RV,          ,           RV,          ,           pV^8  d   K1  W4,           ^8:  d   K@  \        W4,
          4      ^8  d/   \        WB,
          4      ^8  d   \        W#,
          4      ^8  d   K  V P                  P                  V P                  W#V4      4       K  	  K  	  K  	  \        P                  ^\        P                  ^	\        P                  ^	/V n        R# )i    gz6?g,C?g]m{?N)super__init__r   file_color_mappingallowed_colorsZrangeZabsZappend_get_ansi_codeloggingWARNINGERRORFATALlevel_based_colors)selfr   rgbZ
brightness	__class__s   &&    r	   r   ZColorfulFormatter.__init__&   s    $24 !q!A1a[q!A!'!fqj!86A:!EJ!A~ !uz 15zA~#ae*q.SZ!^ ''..t/B/B1/KL! % ! * OORMM1MM1#
r   c                s2   < V ^8  d   QhRS[ RS[ RS[ RS[ /# )r   r   r   r   return)intr   r   r	   r
   r   H   s)     + + + + + +r   c                sL    ^V,           ^V,          ,           ^$V,          ,           # )i    )r   r   r   r   s   &&&&r	   r   Z ColorfulFormatter._get_ansi_codeH   s    AvQ26**r   c                s&   < V ^8  d   QhRS[ RS[/# )r   wordr   )Zstrr   r   r   r	   r
   r   K   s     * *3 *3 *r   c                s    \        V Uu. uF  p\        V4      NK  	  up4      pV\        V P                  4      ,          pV P                  V,          # u upi )z)Convert a word to a 8bit ansi color code.)ZsumZordZlenr   )r   r   ZcharZ	digit_sumZindex   &&   r	   _word_to_colorZ ColorfulFormatter._word_to_colorK   sJ    t4ttTt45	C 3 344""5)) 5s   Ac                4   < V ^8  d   QhRS[ P                  /# r   recordr   Z	LogRecordr   r   r	   r
   r   Q   s      0A0A r   c                sB   V P                   P                  VP                  4      e   V P                   VP                  ,          # V P                  VP                  4      pV P                   P                  VP                  4      f   W P                   VP                  &   V# )z9Get the color that represents the source file of the log.)r   getZfilenamer!   )r   r$   colors   && r	   _allocate_debug_log_colorZ+ColorfulFormatter._allocate_debug_log_colorQ   sx    ""&&v7C**6??;;##FOO4""&&v7?7<##FOO4r   c                s    \         P                  ^ ,          pVP                  R4      R,          pRV9   d   VP                  RR4      pVR8X  d   RpV# )z3Generate a beaitiful to read name for this process.Z/zinput-remapper-Z ZgtkZGUIi)sysargvZsplitreplace)r   Zprocess_pathZprocess_names   &  r	   _get_process_nameZ#ColorfulFormatter._get_process_name^   sR    xx{#))#.r2,'//0A2FL5  Lr   c                r"   r#   r%   r   r   r	   r
   r   k   s      '"3"3 r   c           
     s   VP                   \        P                  8X  d   V P                  '       g   R# V P                  '       g-   V P                  P                  VP                   ^	4      pRV R2# V P                  V4      pVP                   \        P                  \        P                  \        P                  39   d   RV R2pMRV R2pV P                  \        P                  ! 4        \        P                  ^ ,           24      p\        P                   ! 4       P#                  R4       RV R\        P                  ! 4        RV P%                  4        R	V R
2
P'                  RR4      # )z!Generate a message format string.z%(message)sz[38;5;zm%(levelname)s[0m: %(message)sz	[4;38;5;Zmz%H:%M:%S.%fz [38;5;Z z [0mz6%(levelname)s %(filename)s:%(lineno)d: %(message)s[0mz  )Zlevelnor   ZINFOr   r   r&   r(   r   r   r   r!   osZgetpidr)   r*   r    ZnowZstrftimer,   r+   )r   r$   r'   ZstyleZprocess_colorr    r	   _get_formatZColorfulFormatter._get_formatk   s,   >>W\\)$/// ++//BEw&HII..v6>>gmmW__gmmLL"5'+E q)E++ryy{mCHHQK=,IJ ||~&&}56 7&qyy{m1%%'( )g	 '$
	r   c                r"   r#   r%   r   r   r	   r
   r      s     & &W.. &r   c                sb   < V P                  V4      V P                  n        \        SV `  V4      # )zOverwritten format function.)r.   Z_styleZ_fmtr   r   )r   r$   r   s   &&r	   r   ZColorfulFormatter.format   s+      ++F3w~f%%r   )r   r   r   r   )F)Z__name__Z
__module__Z__qualname__Z__firstlineno____doc__r   r   r!   r(   r,   r.   r   Z__static_attributes__Z__classdictcell__Z__classcell__)r   r   s   @@r	   r   r      sR      
  
D+ +* *  @& & &r   r   )	r/   r   r-   r)   r    Ztypingr   Z	Formatterr   r   r   r	   <module>r0      s-   ( (  	 
  r&)) r&r   