
    	^c.                     B    d Z ddlZddlmZ dZ G d d          Zd ZdS )a:  send ui.log() data to a subprocess (EXPERIMENTAL)

This extension lets you specify a shell command per ui.log() event,
sending all remaining arguments to as environment variables to that command.

Positional arguments construct a log message, which is passed in the `MSG1`
environment variables. Each keyword argument is set as a `OPT_UPPERCASE_KEY`
variable (so the key is uppercased, and prefixed with `OPT_`). The original
event name is passed in the `EVENT` environment variable, and the process ID
of mercurial is given in `HGPID`.

So given a call `ui.log('foo', 'bar %s
', 'baz', spam='eggs'), a script
configured for the `foo` event can expect an environment with `MSG1=bar baz`,
and `OPT_SPAM=eggs`.

Scripts are configured in the `[logtoprocess]` section, each key an event name.
For example::

  [logtoprocess]
  commandexception = echo "$MSG1" > /var/log/mercurial_exceptions.log

would log the warning message and traceback of any failed command dispatch.

Scripts are run asynchronously as detached daemon processes; mercurial will
not ensure that they exit cleanly.

    N)procutils   ships-with-hg-corec                   $    e Zd ZdZd Zd Zd ZdS )processloggerz_Map log events to external commands

    Arguments are passed on as environment variables.
    c                 T    t          |                    d                    | _        d S Ns   logtoprocess)dictconfigitems_scripts)selfuis     4/usr/lib/python3/dist-packages/hgext/logtoprocess.py__init__zprocesslogger.__init__5   s!    R^^O<<==    c                 P    t          | j                            |                    S )N)boolr
   get)r   events     r   trackedzprocesslogger.tracked8   s     DM%%e,,---r   c                 J   | j         |         }d}t          |          |k    r|d |         dz   }|t          j                    |d}|                    d |                                D                        t          j        |          }t          j        ||d           d S )Ni s    (truncated))s   EVENTs   HGPIDs   MSG1c              3   N   K   | ] \  }}d |                                 z  |fV  !dS )s   OPT_%sN)upper).0keyvalues      r   	<genexpr>z$processlogger.log.<locals>.<genexpr>J   sI       
 
1;eY$e,
 
 
 
 
 
r   T)shell)	r
   lenosgetpidupdateitemsr   shellenvironrunbgcommand)	r   r   r   msgoptsscriptmaxmsgenvfullenvs	            r   logzprocesslogger.log;   s    u%s88f
 gvg,0Cikk
 
 	

 
 
?Czz||
 
 
 	
 	
 	
 ',,fgT::::::r   N)__name__
__module____qualname____doc__r   r   r*    r   r   r   r   /   sK         
> > >. . .; ; ; ; ;r   r   c                 L    |                      dt          |                      d S r   )	setloggerr   )r   s    r   
uipopulater2   Q   s$    LL-"3"344444r   )r.   r   mercurial.utilsr   
testedwithr   r2   r/   r   r   <module>r5      su    : 
			 $ $ $ $ $ $ #
; ; ; ; ; ; ; ;D5 5 5 5 5r   