208 based stream to fout. |
197 based stream to fout. |
209 """ |
198 """ |
210 def __init__(self, ui, repo, fin, fout): |
199 def __init__(self, ui, repo, fin, fout): |
211 self.cwd = encoding.getcwd() |
200 self.cwd = encoding.getcwd() |
212 |
201 |
213 if ui.config("cmdserver", "log") == '-': |
|
214 global logfile |
|
215 # switch log stream to the 'd' (debug) channel |
|
216 logfile = channeledoutput(fout, 'd') |
|
217 |
|
218 if repo: |
202 if repo: |
219 # the ui here is really the repo ui so take its baseui so we don't |
203 # the ui here is really the repo ui so take its baseui so we don't |
220 # end up with its local configuration |
204 # end up with its local configuration |
221 self.ui = repo.baseui |
205 self.ui = repo.baseui |
222 self.repo = repo |
206 self.repo = repo |
223 self.repoui = repo.ui |
207 self.repoui = repo.ui |
224 else: |
208 else: |
225 self.ui = ui |
209 self.ui = ui |
226 self.repo = self.repoui = None |
210 self.repo = self.repoui = None |
227 |
211 |
228 self.cdebug = logfile |
212 self.cdebug = channeledoutput(fout, 'd') |
229 self.cerr = channeledoutput(fout, 'e') |
213 self.cerr = channeledoutput(fout, 'e') |
230 self.cout = channeledoutput(fout, 'o') |
214 self.cout = channeledoutput(fout, 'o') |
231 self.cin = channeledinput(fin, fout, 'I') |
215 self.cin = channeledinput(fin, fout, 'I') |
232 self.cresult = channeledoutput(fout, 'r') |
216 self.cresult = channeledoutput(fout, 'r') |
233 |
217 |
374 """ |
358 """ |
375 # developer config: cmdserver.log |
359 # developer config: cmdserver.log |
376 logpath = ui.config(b'cmdserver', b'log') |
360 logpath = ui.config(b'cmdserver', b'log') |
377 if not logpath: |
361 if not logpath: |
378 return |
362 return |
379 tracked = {b'cmdserver'} |
363 tracked = {b'chgserver', b'cmdserver'} |
380 |
|
381 global logfile |
|
382 if logpath == b'-': |
|
383 logfile = ui.ferr |
|
384 else: |
|
385 logfile = open(logpath, 'ab') |
|
386 |
364 |
387 if logpath == b'-' and fp: |
365 if logpath == b'-' and fp: |
388 logger = loggingutil.fileobjectlogger(fp, tracked) |
366 logger = loggingutil.fileobjectlogger(fp, tracked) |
389 elif logpath == b'-': |
367 elif logpath == b'-': |
390 logger = loggingutil.fileobjectlogger(ui.ferr, tracked) |
368 logger = loggingutil.fileobjectlogger(ui.ferr, tracked) |