WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
172876
webkitpy: Add contextmanager to disable logging for a block
https://bugs.webkit.org/show_bug.cgi?id=172876
Summary
webkitpy: Add contextmanager to disable logging for a block
Jonathan Bedard
Reported
2017-06-02 15:23:18 PDT
We need a contextmanager which disables logging in a block and renables logging on exit. Currently, OutputCapture only provides functions to disable and then re-enable logging.
Attachments
Patch
(2.92 KB, patch)
2017-06-02 15:51 PDT
,
Jonathan Bedard
no flags
Details
Formatted Diff
Diff
Patch
(3.00 KB, patch)
2017-06-02 16:53 PDT
,
Jonathan Bedard
no flags
Details
Formatted Diff
Diff
Patch for landing
(3.25 KB, patch)
2017-06-03 08:34 PDT
,
Jonathan Bedard
no flags
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2017-06-02 15:33:07 PDT
<
rdar://problem/32546391
>
Jonathan Bedard
Comment 2
2017-06-02 15:51:07 PDT
Created
attachment 311877
[details]
Patch
Daniel Bates
Comment 3
2017-06-02 16:35:07 PDT
Comment on
attachment 311877
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=311877&action=review
> Tools/Scripts/webkitpy/common/system/outputcapture.py:36 > +from contextlib import contextmanager > from StringIO import StringIO
These imports should be sorted based on the UNIX sort command.
> Tools/Scripts/webkitpy/common/system/outputcapture.py:112 > +class Suppressor(OutputCapture):
Maybe a better name for this would be OutputCaptureScope?
> Tools/Scripts/webkitpy/common/system/outputcapture.py:116 > + self.last_log = None
I suggest that we use the same terminology as used in OutputCapture and call this captured_output.
> Tools/Scripts/webkitpy/common/system/outputcapture.py:123 > + @contextmanager > + def suppress_logging(self): > + self.capture_output() > + yield > + self.last_log = self.restore_output() > +
Instead of using @contextmanager can we have this class implement __enter__() and __exit__() itself so that we can make use of this convenience class using the following syntax: scope = OutputCaptureScope() with scope: ... scope.captured_output
Daniel Bates
Comment 4
2017-06-02 16:37:25 PDT
Comment on
attachment 311877
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=311877&action=review
>> Tools/Scripts/webkitpy/common/system/outputcapture.py:112 >> +class Suppressor(OutputCapture): > > Maybe a better name for this would be OutputCaptureScope?
We may want to have this class take the OutputCapture instance instead of extending it to make it easy to use this class correctly and hard to use it incorrectly or un-idiomatic.
Jonathan Bedard
Comment 5
2017-06-02 16:53:33 PDT
Created
attachment 311886
[details]
Patch
Daniel Bates
Comment 6
2017-06-02 17:09:02 PDT
Comment on
attachment 311886
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=311886&action=review
> Tools/Scripts/webkitpy/common/system/outputcapture.py:114 > + self.captured_output = None
This should return (None, None, None) to match up with how restore_output() behaves.
> Tools/Scripts/webkitpy/common/system/outputcapture_unittest.py:61 > + def test_output_capture_scope(self):
Please add a test where OutputScope takes an OutputCapture as an argument.
Daniel Bates
Comment 7
2017-06-02 19:16:30 PDT
Comment on
attachment 311886
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=311886&action=review
> Tools/Scripts/webkitpy/common/system/outputcapture.py:120 > + self.captured_output = self._output_capture.restore_output()
exc_val => exc_value exc_tb => traceback (To match
https://docs.python.org/2/reference/datamodel.html#context-managers
)
Jonathan Bedard
Comment 8
2017-06-03 08:34:19 PDT
Created
attachment 311927
[details]
Patch for landing
WebKit Commit Bot
Comment 9
2017-06-03 09:11:34 PDT
Comment on
attachment 311927
[details]
Patch for landing Clearing flags on attachment: 311927 Committed
r217758
: <
http://trac.webkit.org/changeset/217758
>
WebKit Commit Bot
Comment 10
2017-06-03 09:11:35 PDT
All reviewed patches have been landed. Closing bug.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug