commandserver: turn server debug messages into logs
authorYuya Nishihara <yuya@tcha.org>
Sun, 18 Nov 2018 19:55:53 +0900
changeset 53593 25e9089c7686be81d3500432be008ef08a142487
parent 53592 d23fd01cc1156fcb856299e009796066fbde15db
child 53594 77173267878b2afdb8280538b91873cfa4071ff7
push id1079
push usergszorc@mozilla.com
push dateMon, 10 Dec 2018 19:44:59 +0000
commandserver: turn server debug messages into logs They were ui.debug() just because commandserver.log() was noop if no client connected.
mercurial/chgserver.py
mercurial/commandserver.py
tests/test-chg.t
--- a/mercurial/chgserver.py
+++ b/mercurial/chgserver.py
@@ -601,20 +601,21 @@ class chgunixservicehandler(object):
         # it is possible to have a race condition here that we may
         # remove another server's socket file. but that's okay
         # since that server will detect and exit automatically and
         # the client will start a new server on demand.
         util.tryunlink(self._realaddress)
 
     def shouldexit(self):
         if not self._issocketowner():
-            self.ui.debug('%s is not owned, exiting.\n' % self._realaddress)
+            self.ui.log(b'chgserver', b'%s is not owned, exiting.\n',
+                        self._realaddress)
             return True
         if time.time() - self._lastactive > self._idletimeout:
-            self.ui.debug('being idle too long. exiting.\n')
+            self.ui.log(b'chgserver', b'being idle too long. exiting.\n')
             return True
         return False
 
     def newconnection(self):
         self._lastactive = time.time()
 
     def createcmdserver(self, repo, conn, fin, fout):
         return chgcmdserver(self.ui, repo, fin, fout, conn,
--- a/mercurial/commandserver.py
+++ b/mercurial/commandserver.py
@@ -568,17 +568,18 @@ class unixforkingservice(object):
             except socket.error as inst:
                 if inst.args[0] == errno.EINTR:
                     continue
                 raise
 
             pid = os.fork()
             if pid:
                 try:
-                    self.ui.debug('forked worker process (pid=%d)\n' % pid)
+                    self.ui.log(b'cmdserver',
+                                b'forked worker process (pid=%d)\n', pid)
                     self._workerpids.add(pid)
                     h.newconnection()
                 finally:
                     conn.close()  # release handle in parent process
             else:
                 try:
                     selector.close()
                     self._sock.close()
@@ -605,17 +606,17 @@ class unixforkingservice(object):
                 if inst.errno != errno.ECHILD:
                     raise
                 # no child processes at all (reaped by other waitpid()?)
                 self._workerpids.clear()
                 return
             if pid == 0:
                 # no waitable child processes
                 return
-            self.ui.debug('worker process exited (pid=%d)\n' % pid)
+            self.ui.log(b'cmdserver', b'worker process exited (pid=%d)\n', pid)
             self._workerpids.discard(pid)
 
     def _runworker(self, conn):
         signal.signal(signal.SIGCHLD, self._oldsigchldhandler)
         _initworkerprocess()
         h = self._servicehandler
         try:
             _serverequest(self.ui, self.repo, conn, h.createcmdserver)
--- a/tests/test-chg.t
+++ b/tests/test-chg.t
@@ -225,18 +225,18 @@ check that server events are recorded:
   $ ls log
   server.log
   server.log.1
 
 print only the last 10 lines, since we aren't sure how many records are
 preserved:
 
   $ cat log/server.log.1 log/server.log | tail -10 | filterlog
-  YYYY/MM/DD HH:MM:SS (PID)> confighash = ... mtimehash = ...
-  YYYY/MM/DD HH:MM:SS (PID)> validate: []
-  YYYY/MM/DD HH:MM:SS (PID)> confighash = ... mtimehash = ...
+  YYYY/MM/DD HH:MM:SS (PID)> forked worker process (pid=...)
   YYYY/MM/DD HH:MM:SS (PID)> setprocname: ...
   YYYY/MM/DD HH:MM:SS (PID)> received fds: ...
   YYYY/MM/DD HH:MM:SS (PID)> chdir to '$TESTTMP/extreload'
   YYYY/MM/DD HH:MM:SS (PID)> setumask 18
   YYYY/MM/DD HH:MM:SS (PID)> setenv: ...
   YYYY/MM/DD HH:MM:SS (PID)> confighash = ... mtimehash = ...
   YYYY/MM/DD HH:MM:SS (PID)> validate: []
+  YYYY/MM/DD HH:MM:SS (PID)> worker process exited (pid=...)
+  YYYY/MM/DD HH:MM:SS (PID)> $TESTTMP/extreload/chgsock/server-... is not owned, exiting.