watchman: optionally log watchman commands via ui.log

Summary:
This helps debugging watchman related issues. In particular, the order of
watchman state-enter/leave events and other events.

Reviewed By: singhsrb

Differential Revision: D7648928

fbshipit-source-id: 527a7bef9a07c2526bdd40ad802d5ba06bc27226
This commit is contained in:
Jun Wu 2018-04-16 20:42:04 -07:00 committed by Facebook Github Bot
parent 857e9aa714
commit 2f37dcb182

View File

@ -82,13 +82,19 @@ class client(object):
def _command(self, *args): def _command(self, *args):
watchmanargs = (args[0], self._root) + args[1:] watchmanargs = (args[0], self._root) + args[1:]
self._ui.log('watchman-command',
'watchman command %r started with timeout = %s',
watchmanargs, self._timeout)
try: try:
if self._watchmanclient is None: if self._watchmanclient is None:
self._firsttime = False self._firsttime = False
self._watchmanclient = pywatchman.client( self._watchmanclient = pywatchman.client(
timeout=self._timeout, timeout=self._timeout,
useImmutableBser=True) useImmutableBser=True)
return self._watchmanclient.query(*watchmanargs) result = self._watchmanclient.query(*watchmanargs)
self._ui.log('watchman-command',
'watchman command %r completed', watchmanargs)
return result
except pywatchman.CommandError as ex: except pywatchman.CommandError as ex:
if 'unable to resolve root' in ex.msg: if 'unable to resolve root' in ex.msg:
raise WatchmanNoRoot(self._root, ex.msg) raise WatchmanNoRoot(self._root, ex.msg)