##// END OF EJS Templates
commandserver: enable logging when server process started...
Yuya Nishihara -
r40858:368ecbf7 default
parent child Browse files
Show More
@@ -208,15 +208,10 b' class server(object):'
208 208 def __init__(self, ui, repo, fin, fout):
209 209 self.cwd = encoding.getcwd()
210 210
211 # developer config: cmdserver.log
212 logpath = ui.config("cmdserver", "log")
213 if logpath:
211 if ui.config("cmdserver", "log") == '-':
214 212 global logfile
215 if logpath == '-':
216 # write log on a special 'd' (debug) channel
217 logfile = channeledoutput(fout, 'd')
218 else:
219 logfile = open(logpath, 'a')
213 # switch log stream to the 'd' (debug) channel
214 logfile = channeledoutput(fout, 'd')
220 215
221 216 if repo:
222 217 # the ui here is really the repo ui so take its baseui so we don't
@@ -361,6 +356,24 b' class server(object):'
361 356
362 357 return 0
363 358
359 def setuplogging(ui):
360 """Set up server logging facility
361
362 If cmdserver.log is '-', log messages will be sent to the 'd' channel
363 while a client is connected. Otherwise, messages will be written to
364 the stderr of the server process.
365 """
366 # developer config: cmdserver.log
367 logpath = ui.config(b'cmdserver', b'log')
368 if not logpath:
369 return
370
371 global logfile
372 if logpath == b'-':
373 logfile = ui.ferr
374 else:
375 logfile = open(logpath, 'ab')
376
364 377 class pipeservice(object):
365 378 def __init__(self, ui, repo, opts):
366 379 self.ui = ui
@@ -155,9 +155,11 b' def runservice(opts, parentfn=None, init'
155 155 def _createcmdservice(ui, repo, opts):
156 156 mode = opts['cmdserver']
157 157 try:
158 return _cmdservicemap[mode](ui, repo, opts)
158 servicefn = _cmdservicemap[mode]
159 159 except KeyError:
160 160 raise error.Abort(_('unknown mode %s') % mode)
161 commandserver.setuplogging(ui)
162 return servicefn(ui, repo, opts)
161 163
162 164 def _createhgwebservice(ui, repo, opts):
163 165 # this way we can check if something was given in the command-line
General Comments 0
You need to be logged in to leave comments. Login now