ó
2…6ic           @  s¨   d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l	 Z	 d  d l
 Z
 d Z d e f d „  ƒ  YZ i  Z e e e d „ Z d S(   iÿÿÿÿ(   t   print_functionNt   LogFilec           B  s;   e  Z d  Z e e e d „ Z d „  Z d „  Z d „  Z RS(   s+   
    This manages one of our logfiles.
    c         C  sd   | |  _  | |  _ | |  _ | |  _ d |  _ d |  _ d |  _ t |  _	 t
 j r` t j |  _ n  d S(   s©  
        `name`
            The name of the logfile, without the .txt extension.
        `append`
            If true, we will append to the logfile. If false, we will truncate
            it to an empty file the first time we write to it.
        `developer`
            If true, nothing happens if config.developer is not set to True.
        `flush`
            Determines if the file is flushed after each write.
        i    N(   t   namet   appendt	   developert   flusht   Nonet   filet	   softspacet   newlinest   Falset	   raw_writet   renpyt   iost   syst   stdout(   t   selfR   R   R   R   (    (    sX   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\log.pyt   __init__,   s    									c         C  sä  |  j  r t St j r t S|  j r4 t j j r4 t St j j sD t Sy‘t j	 j
 d t j j ƒ } t j j | |  j d ƒ } t j j t j ƒ  d |  j d ƒ } t j r½ t d | ƒ n  |  j rÏ d } n d } t j j rð t j |  _  n> y t j | | d ƒ |  _  Wn t j | | d ƒ |  _  n X|  j re|  j d ƒ |  j d	 d
 ƒ |  j d ƒ n  |  j d t j ƒ  ƒ |  j d t j ƒ  ƒ |  j d t j ƒ |  j d t j j t j j ƒ |  j d ƒ t SWn t SXd  S(   Nt   RENPY_LOG_BASEs   .txts   renpy-s
   Logging tot   at   ws   utf-8t    t   =iN   s   %ss   %s %s(   R   t   TrueR   t   macappR
   R   t   configt
   log_enablet   ost   environt   gett   logdirt   patht   joinR   t   tempfilet
   gettempdirt   androidt   printR   t   log_to_stdoutR   R   t   codecst   opent   writet   timet   ctimet   platformt   version(   R   t   baset   fnt   altfnt   mode(    (    sX   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\log.pyR'   I   sF    		&				c         G  s   |  j  ƒ  r‹ |  j s, | | } | d 7} n  t | t ƒ sM | j d ƒ } n  | j d d ƒ } |  j j | ƒ |  j r‹ |  j j ƒ  q‹ n  d S(   sF   
        Formats `s` with args, and writes it to the logfile.
        s   
s   latin-1s   
N(	   R'   R   t
   isinstancet   unicodet   decodet   replaceR   R(   R   (   R   t   st   args(    (    sX   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\log.pyR(      s    	
	c         C  s&   t  |  _ t j d |  ƒ t |  _ d S(   s6   
        Writes the exception to the logfile.
        N(   R   R   t	   tracebackt	   print_excR   R
   (   R   (    (    sX   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\log.pyt	   exception”   s    	(	   t   __name__t
   __module__t   __doc__R
   R   R   R'   R(   R9   (    (    (    sX   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\log.pyR   '   s
   	6	c         C  sM   t  j |  d  ƒ } | d  k rI t |  d | d | d | ƒ} | t  |  <n  | S(   NR   R   R   (   t	   log_cacheR   R   R   (   R   R   R   R   t   rv(    (    sX   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\log.pyR'   ¡   s
    (   t
   __future__R    t   os.pathR   R&   R7   R+   R)   R!   R   R   R   t   log_filet   objectR   R=   R
   R'   (    (    (    sX   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\log.pyt   <module>   s   w