68 # Failed to apply the arguments, ignore |
70 # Failed to apply the arguments, ignore |
69 formatted = msg[0] |
71 formatted = msg[0] |
70 messages = (formatted,) + msg[1:] |
72 messages = (formatted,) + msg[1:] |
71 else: |
73 else: |
72 messages = msg |
74 messages = msg |
|
75 env = { |
|
76 b'EVENT': event, |
|
77 b'HGPID': os.getpid(), |
|
78 } |
73 # positional arguments are listed as MSG[N] keys in the |
79 # positional arguments are listed as MSG[N] keys in the |
74 # environment |
80 # environment |
75 msgpairs = ( |
81 env.update((b'MSG%d' % i, m) for i, m in enumerate(messages, 1)) |
76 ('MSG{0:d}'.format(i), m) |
|
77 for i, m in enumerate(messages, 1)) |
|
78 # keyword arguments get prefixed with OPT_ and uppercased |
82 # keyword arguments get prefixed with OPT_ and uppercased |
79 optpairs = ( |
83 env.update((b'OPT_%s' % key.upper(), value) |
80 ('OPT_{0}'.format(key.upper()), value) |
84 for key, value in pycompat.byteskwargs(opts).items()) |
81 for key, value in opts.iteritems()) |
|
82 env = dict(itertools.chain(msgpairs, optpairs), |
|
83 EVENT=event, HGPID=os.getpid()) |
|
84 fullenv = procutil.shellenviron(env) |
85 fullenv = procutil.shellenviron(env) |
85 procutil.runbgcommand(script, fullenv, shell=True) |
86 procutil.runbgcommand(script, fullenv, shell=True) |
86 return super(logtoprocessui, self).log(event, *msg, **opts) |
87 return super(logtoprocessui, self).log(event, *msg, **opts) |
87 |
88 |
88 # Replace the class for this instance and all clones created from it: |
89 # Replace the class for this instance and all clones created from it: |