
    uu<h                     n    d dl Z d dlZd dlZd dlZ G d d      Z G d de j
                        Zd Zd Zy)    Nc                   0    e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zy
)logcolorz[94mz[96mz[91mz[92mz[93mz[0mz[95mz[1mz[4mN)__name__
__module____qualname__INFO	REFERENCEERRORSUCCESSWARNINGENDCHEADERBOLD	UNDERLINE     ;/mounts/lovelace/software/shotgun-workflow/dev/tools/log.pyr   r      s/    DIEGGDFDIr   r   c                   :    e Zd ZdZ ej
                  d      Zd Zy)NoColorFormatterzZ
    Log formatter that strips terminal colour
    escape codes from the log message.
    z%\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])c           	         t        j                  dt        j                               dt        j                  | j
                  d|j                        dt        j                  | j
                  d|j                        S )z4Return logger message with terminal escapes removed.z%Y-%m-%d %H:%M:%S  )timestrftime	localtimeresubANSI_RE	levelnamemsg)selfrecords     r   formatzNoColorFormatter.format   sV     MM-t~~/?@FF4<<V%5%56FF4<<VZZ0
 	
r   N)r   r   r   __doc__r   compiler   r#   r   r   r   r   r      s     bjjABG
r   r   c                 $   t        j                         }|j                  t         j                         t        j                  d      }t               }t        j                  t        j                        }|j                  t         j                         |j                  |       t        j                  | dd      }|j                  t         j                         |j                  |       |j                  |       |j                  |       |S )Nz%(message)swutf8)modeencoding)logging	getLoggersetLevelr   	Formatterr   StreamHandlersysstdoutDEBUGsetFormatterFileHandler
addHandler)logpathloggerstdformatterfileformatterstdout_handlerfile_handlers         r   build_loggerr<       s     F
OOGLL!$$]3L$&M **3::6NGMM*- &&wS6JL'--(m,
l#
n%Mr   c                 V   g }t        | dz        }|r|j                  | d       t        | dz  dz        }|r|j                  | d       | dz  }|s|sC|j                         r|j                  t        |       d       n|j                  |dd       dj                  |      S )Ni  h<   msz.2fz, )intappend
is_integerjoin)secondspartshoursminutessecss        r   human_readable_timerK   6   s    E4 Ewa[!7T>b()Gy]#R<D5??LLCI;a)LLD:Q(99Ur   )	r+   r0   r   r   r   r.   r   r<   rK   r   r   r   <module>rL      s1     
 

w(( 
",r   