Patchwork [8,of,8] commandserver: turn server debug messages into logs

login
register
mail settings
Submitter Yuya Nishihara
Date Dec. 4, 2018, 1:24 p.m.
Message ID <ea51845e5a0401ccdd0f.1543929862@mimosa>
Download mbox | patch
Permalink /patch/36955/
State Accepted
Headers show

Comments

Yuya Nishihara - Dec. 4, 2018, 1:24 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1542538553 -32400
#      Sun Nov 18 19:55:53 2018 +0900
# Node ID ea51845e5a0401ccdd0ff2a5ea1353a391e0552b
# Parent  05530c3d01119b718a9fb8ca4ef60ae9624441cd
commandserver: turn server debug messages into logs

They were ui.debug() just because commandserver.log() was noop if no client
connected.

Patch

diff --git a/mercurial/chgserver.py b/mercurial/chgserver.py
--- a/mercurial/chgserver.py
+++ b/mercurial/chgserver.py
@@ -606,10 +606,11 @@  class chgunixservicehandler(object):
 
     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
 
diff --git a/mercurial/commandserver.py b/mercurial/commandserver.py
--- a/mercurial/commandserver.py
+++ b/mercurial/commandserver.py
@@ -565,7 +565,8 @@  class unixforkingservice(object):
             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:
@@ -602,7 +603,7 @@  class unixforkingservice(object):
             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):
diff --git a/tests/test-chg.t b/tests/test-chg.t
--- a/tests/test-chg.t
+++ b/tests/test-chg.t
@@ -230,9 +230,7 @@  print only the last 10 lines, since we a
 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'
@@ -240,3 +238,5 @@  preserved:
   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.