- Revision
- 204275
- Author
- aakash_j...@apple.com
- Date
- 2016-08-08 18:17:52 -0700 (Mon, 08 Aug 2016)
Log Message
Some EWS console logs doesn't go to log file
https://bugs.webkit.org/show_bug.cgi?id=160585
rdar://problem/24464570
Reviewed by Daniel Bates.
* Scripts/webkitpy/common/system/logutils.py:
(FileSystemHandler._open): Ensure that we open logfile in append mode in order to avoid
any possible overwriting.
* Scripts/webkitpy/common/system/filesystem.py:
(FileSystem.open_text_file_for_writing): Add should_append parameter to append to file.
* Scripts/webkitpy/common/system/filesystem_mock.py:
(MockFileSystem.open_text_file_for_writing): Same.
* Scripts/webkitpy/common/system/filesystem_unittest.py:
(RealFileSystemTest.test_read_and_write_text_file): Removed unused variable 'hex_equivalent'.
(RealFileSystemTest.test_append_to_text_file): Added new unit test for testing append functionality.
* Scripts/webkitpy/tool/commands/queues.py:
(AbstractQueue.begin_work_queue): Configure the logger for overall webkitpy to log to file.
This will ensure that all the sub-modules inside webkitpy will log to file.
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (204274 => 204275)
--- trunk/Tools/ChangeLog 2016-08-09 01:06:50 UTC (rev 204274)
+++ trunk/Tools/ChangeLog 2016-08-09 01:17:52 UTC (rev 204275)
@@ -1,3 +1,25 @@
+2016-08-08 Aakash Jain <aakash_j...@apple.com>
+
+ Some EWS console logs doesn't go to log file
+ https://bugs.webkit.org/show_bug.cgi?id=160585
+ rdar://problem/24464570
+
+ Reviewed by Daniel Bates.
+
+ * Scripts/webkitpy/common/system/logutils.py:
+ (FileSystemHandler._open): Ensure that we open logfile in append mode in order to avoid
+ any possible overwriting.
+ * Scripts/webkitpy/common/system/filesystem.py:
+ (FileSystem.open_text_file_for_writing): Add should_append parameter to append to file.
+ * Scripts/webkitpy/common/system/filesystem_mock.py:
+ (MockFileSystem.open_text_file_for_writing): Same.
+ * Scripts/webkitpy/common/system/filesystem_unittest.py:
+ (RealFileSystemTest.test_read_and_write_text_file): Removed unused variable 'hex_equivalent'.
+ (RealFileSystemTest.test_append_to_text_file): Added new unit test for testing append functionality.
+ * Scripts/webkitpy/tool/commands/queues.py:
+ (AbstractQueue.begin_work_queue): Configure the logger for overall webkitpy to log to file.
+ This will ensure that all the sub-modules inside webkitpy will log to file.
+
2016-08-08 Simon Fraser <simon.fra...@apple.com>
Have the iOS platform interit from the Apple platform in webkitpy
Modified: trunk/Tools/Scripts/webkitpy/common/system/filesystem.py (204274 => 204275)
--- trunk/Tools/Scripts/webkitpy/common/system/filesystem.py 2016-08-09 01:06:50 UTC (rev 204274)
+++ trunk/Tools/Scripts/webkitpy/common/system/filesystem.py 2016-08-09 01:17:52 UTC (rev 204275)
@@ -235,7 +235,9 @@
# not being seekable. See http://stackoverflow.com/questions/1510188/can-seek-and-tell-work-with-utf-8-encoded-documents-in-python .
return codecs.open(path, 'r', 'utf8', errors)
- def open_text_file_for_writing(self, path):
+ def open_text_file_for_writing(self, path, should_append=False):
+ if should_append:
+ return codecs.open(path, 'a', 'utf8')
return codecs.open(path, 'w', 'utf8')
def open_stdin(self):
Modified: trunk/Tools/Scripts/webkitpy/common/system/filesystem_mock.py (204274 => 204275)
--- trunk/Tools/Scripts/webkitpy/common/system/filesystem_mock.py 2016-08-09 01:06:50 UTC (rev 204274)
+++ trunk/Tools/Scripts/webkitpy/common/system/filesystem_mock.py 2016-08-09 01:17:52 UTC (rev 204275)
@@ -337,7 +337,7 @@
self._raise_not_found(path)
return ReadableTextFileObject(self, path, self.files[path])
- def open_text_file_for_writing(self, path):
+ def open_text_file_for_writing(self, path, should_append=False):
return WritableTextFileObject(self, path)
def read_text_file(self, path):
Modified: trunk/Tools/Scripts/webkitpy/common/system/filesystem_unittest.py (204274 => 204275)
--- trunk/Tools/Scripts/webkitpy/common/system/filesystem_unittest.py 2016-08-09 01:06:50 UTC (rev 204274)
+++ trunk/Tools/Scripts/webkitpy/common/system/filesystem_unittest.py 2016-08-09 01:17:52 UTC (rev 204275)
@@ -187,7 +187,6 @@
text_path = None
unicode_text_string = u'\u016An\u012Dc\u014Dde\u033D'
- hex_equivalent = '\xC5\xAA\x6E\xC4\xAD\x63\xC5\x8D\x64\x65\xCC\xBD'
try:
text_path = tempfile.mktemp(prefix='tree_unittest_')
file = fs.open_text_file_for_writing(text_path)
@@ -203,6 +202,31 @@
if text_path and fs.isfile(text_path):
os.remove(text_path)
+ def test_append_to_text_file(self):
+ fs = FileSystem()
+ text_path = None
+
+ unicode_text_string1 = u'\u016An\u012Dc\u014Dde\u033D'
+ unicode_text_string2 = 'Hello'
+ try:
+ text_path = tempfile.mktemp(prefix='tree_unittest_')
+ file = fs.open_text_file_for_writing(text_path)
+ file.write(unicode_text_string1)
+ file.close()
+
+ file = fs.open_text_file_for_writing(text_path, should_append=True)
+ file.write(unicode_text_string2)
+ file.close()
+
+ file = fs.open_text_file_for_reading(text_path)
+ read_text = file.read()
+ file.close()
+
+ self.assertEqual(read_text, unicode_text_string1 + unicode_text_string2)
+ finally:
+ if text_path and fs.isfile(text_path):
+ os.remove(text_path)
+
def test_read_and_write_file(self):
fs = FileSystem()
text_path = None
Modified: trunk/Tools/Scripts/webkitpy/common/system/logutils.py (204274 => 204275)
--- trunk/Tools/Scripts/webkitpy/common/system/logutils.py 2016-08-09 01:06:50 UTC (rev 204274)
+++ trunk/Tools/Scripts/webkitpy/common/system/logutils.py 2016-08-09 01:17:52 UTC (rev 204275)
@@ -232,4 +232,4 @@
FileHandler.__init__(self, filename)
def _open(self):
- return self.filesystem.open_text_file_for_writing(self.filename)
+ return self.filesystem.open_text_file_for_writing(self.filename, should_append=True)
Modified: trunk/Tools/Scripts/webkitpy/tool/commands/queues.py (204274 => 204275)
--- trunk/Tools/Scripts/webkitpy/tool/commands/queues.py 2016-08-09 01:06:50 UTC (rev 204274)
+++ trunk/Tools/Scripts/webkitpy/tool/commands/queues.py 2016-08-09 01:17:52 UTC (rev 204275)
@@ -123,7 +123,9 @@
raise NotImplementedError, "subclasses must implement"
def begin_work_queue(self):
- logutils.configure_logger_to_log_to_file(_log, self.queue_log_path(), self.host.filesystem)
+ # FIXME: We should stop the logging as well when the queue stops.
+ # We are using logging.getLogger("webkitpy") instead of _log since we want to capture all messages logged from webkitpy modules.
+ logutils.configure_logger_to_log_to_file(logging.getLogger("webkitpy"), self.queue_log_path(), self.host.filesystem)
_log.info("CAUTION: %s will discard all local changes in \"%s\"" % (self.name, self._tool.scm().checkout_root))
if self._options.confirm:
response = self._tool.user.prompt("Are you sure? Type \"yes\" to continue: ")