Show More
@@ -137,6 +137,9 def dispatch(req): | |||
|
137 | 137 | finally: |
|
138 | 138 | duration = util.timer() - starttime |
|
139 | 139 | req.ui.flush() |
|
140 | if req.ui.logblockedtimes: | |
|
141 | req.ui._blockedtimes['command_duration'] = duration * 1000 | |
|
142 | req.ui.log('uiblocked', 'ui blocked ms', **req.ui._blockedtimes) | |
|
140 | 143 | req.ui.log("commandfinish", "%s exited %s after %0.2f seconds\n", |
|
141 | 144 | msg, ret or 0, duration) |
|
142 | 145 | return ret |
@@ -7,6 +7,7 | |||
|
7 | 7 | |
|
8 | 8 | from __future__ import absolute_import |
|
9 | 9 | |
|
10 | import collections | |
|
10 | 11 | import contextlib |
|
11 | 12 | import errno |
|
12 | 13 | import getpass |
@@ -138,6 +139,8 class ui(object): | |||
|
138 | 139 | self.callhooks = True |
|
139 | 140 | # Insecure server connections requested. |
|
140 | 141 | self.insecureconnections = False |
|
142 | # Blocked time | |
|
143 | self.logblockedtimes = False | |
|
141 | 144 | |
|
142 | 145 | if src: |
|
143 | 146 | self.fout = src.fout |
@@ -155,6 +158,7 class ui(object): | |||
|
155 | 158 | self.fixconfig() |
|
156 | 159 | |
|
157 | 160 | self.httppasswordmgrdb = src.httppasswordmgrdb |
|
161 | self._blockedtimes = src._blockedtimes | |
|
158 | 162 | else: |
|
159 | 163 | self.fout = util.stdout |
|
160 | 164 | self.ferr = util.stderr |
@@ -164,6 +168,7 class ui(object): | |||
|
164 | 168 | self.environ = encoding.environ |
|
165 | 169 | |
|
166 | 170 | self.httppasswordmgrdb = httppasswordmgrdbproxy() |
|
171 | self._blockedtimes = collections.defaultdict(int) | |
|
167 | 172 | |
|
168 | 173 | allowed = self.configlist('experimental', 'exportableenviron') |
|
169 | 174 | if '*' in allowed: |
@@ -192,6 +197,15 class ui(object): | |||
|
192 | 197 | self._progbar.resetstate() # reset last-print time of progress bar |
|
193 | 198 | self.httppasswordmgrdb = httppasswordmgrdbproxy() |
|
194 | 199 | |
|
200 | @contextlib.contextmanager | |
|
201 | def timeblockedsection(self, key): | |
|
202 | starttime = util.timer() | |
|
203 | try: | |
|
204 | yield | |
|
205 | finally: | |
|
206 | self._blockedtimes[key + '_blocked'] += \ | |
|
207 | (util.timer() - starttime) * 1000 | |
|
208 | ||
|
195 | 209 | def formatter(self, topic, opts): |
|
196 | 210 | return formatter.formatter(self, topic, opts) |
|
197 | 211 | |
@@ -295,6 +309,7 class ui(object): | |||
|
295 | 309 | self._reportuntrusted = self.debugflag or self.configbool("ui", |
|
296 | 310 | "report_untrusted", True) |
|
297 | 311 | self.tracebackflag = self.configbool('ui', 'traceback', False) |
|
312 | self.logblockedtimes = self.configbool('ui', 'logblockedtimes') | |
|
298 | 313 | |
|
299 | 314 | if section in (None, 'trusted'): |
|
300 | 315 | # update trust information |
@@ -10,6 +10,7 Test if logtoprocess correctly captures | |||
|
10 | 10 | > def foo(ui, repo): |
|
11 | 11 | > ui.log('foo', 'a message: %(bar)s\n', bar='spam') |
|
12 | 12 | > EOF |
|
13 | $ cp $HGRCPATH $HGRCPATH.bak | |
|
13 | 14 | $ cat >> $HGRCPATH << EOF |
|
14 | 15 | > [extensions] |
|
15 | 16 | > logtoprocess= |
@@ -52,3 +53,18 ordering issues between the various proc | |||
|
52 | 53 | logtoprocess commandfinish output: |
|
53 | 54 | logtoprocess foo output: |
|
54 | 55 | spam |
|
56 | ||
|
57 | Confirm that logging blocked time catches stdio properly: | |
|
58 | $ cp $HGRCPATH.bak $HGRCPATH | |
|
59 | $ cat >> $HGRCPATH << EOF | |
|
60 | > [extensions] | |
|
61 | > logtoprocess= | |
|
62 | > pager= | |
|
63 | > [logtoprocess] | |
|
64 | > uiblocked=echo "\$EVENT command \$OPT_COMMAND_DURATION ms" | |
|
65 | > [ui] | |
|
66 | > logblockedtimes=True | |
|
67 | > EOF | |
|
68 | ||
|
69 | $ hg log | |
|
70 | uiblocked command [0-9]+.[0-9]* ms (re) |
General Comments 0
You need to be logged in to leave comments.
Login now