Title: [132840] trunk/Tools
Revision
132840
Author
[email protected]
Date
2012-10-29 12:54:17 -0700 (Mon, 29 Oct 2012)

Log Message

webkitpy: change non-verbose log format for webkit-patch
https://bugs.webkit.org/show_bug.cgi?id=100561

Reviewed by Ojan Vafai.

Logging the module name and the log level is annoying and nearly useless.
For starters, this change removes that unless you are doing verbose/
debug logging. In the future we should split out the concepts of
verbose and debug logging (like we did in test-webkitpy and
run-webkit-tests) so that you could get this in debug logging.

* Scripts/webkitpy/common/system/logutils.py:
(_default_handlers):
(configure_logging):
* Scripts/webkitpy/common/system/logutils_unittest.py:
(ConfigureLoggingTest.test_info_message):
(ConfigureLoggingTest):
(ConfigureLoggingTest.test_debug_message):
(ConfigureLoggingTest.test_two_messages):
(ConfigureLoggingVerboseTest):
(ConfigureLoggingVerboseTest._logging_level):
(ConfigureLoggingVerboseTest.test_info_message):
(ConfigureLoggingVerboseTest.test_debug_message):
(ConfigureLoggingCustomLevelTest.test_logged_message):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (132839 => 132840)


--- trunk/Tools/ChangeLog	2012-10-29 19:37:19 UTC (rev 132839)
+++ trunk/Tools/ChangeLog	2012-10-29 19:54:17 UTC (rev 132840)
@@ -1,3 +1,30 @@
+2012-10-29  Dirk Pranke  <[email protected]>
+
+        webkitpy: change non-verbose log format for webkit-patch
+        https://bugs.webkit.org/show_bug.cgi?id=100561
+
+        Reviewed by Ojan Vafai.
+
+        Logging the module name and the log level is annoying and nearly useless.
+        For starters, this change removes that unless you are doing verbose/
+        debug logging. In the future we should split out the concepts of
+        verbose and debug logging (like we did in test-webkitpy and
+        run-webkit-tests) so that you could get this in debug logging.
+
+        * Scripts/webkitpy/common/system/logutils.py:
+        (_default_handlers):
+        (configure_logging):
+        * Scripts/webkitpy/common/system/logutils_unittest.py:
+        (ConfigureLoggingTest.test_info_message):
+        (ConfigureLoggingTest):
+        (ConfigureLoggingTest.test_debug_message):
+        (ConfigureLoggingTest.test_two_messages):
+        (ConfigureLoggingVerboseTest):
+        (ConfigureLoggingVerboseTest._logging_level):
+        (ConfigureLoggingVerboseTest.test_info_message):
+        (ConfigureLoggingVerboseTest.test_debug_message):
+        (ConfigureLoggingCustomLevelTest.test_logged_message):
+
 2012-10-29  Christophe Dumez  <[email protected]>
 
         [CMAKE] Add TestNetscapePlugIn/Tests/NPRuntimeCallsWithNullNPP.cpp to CMakeLists.txt

Modified: trunk/Tools/Scripts/webkitpy/common/system/logutils.py (132839 => 132840)


--- trunk/Tools/Scripts/webkitpy/common/system/logutils.py	2012-10-29 19:37:19 UTC (rev 132839)
+++ trunk/Tools/Scripts/webkitpy/common/system/logutils.py	2012-10-29 19:54:17 UTC (rev 132840)
@@ -125,7 +125,7 @@
     return logging.getLogger(logger_name)
 
 
-def _default_handlers(stream):
+def _default_handlers(stream, logging_level):
     """Return a list of the default logging handlers to use.
 
     Args:
@@ -148,7 +148,11 @@
 
     # Create the handler.
     handler = logging.StreamHandler(stream)
-    formatter = logging.Formatter("%(name)s: [%(levelname)s] %(message)s")
+    if logging_level == logging.DEBUG:
+        formatter = logging.Formatter("%(name)s: [%(levelname)s] %(message)s")
+    else:
+        formatter = logging.Formatter("%(message)s")
+
     handler.setFormatter(formatter)
     handler.addFilter(logging_filter)
 
@@ -195,7 +199,7 @@
     if stream is None:
         stream = sys.stderr
     if handlers is None:
-        handlers = _default_handlers(stream)
+        handlers = _default_handlers(stream, logging_level)
 
     logger.setLevel(logging_level)
 

Modified: trunk/Tools/Scripts/webkitpy/common/system/logutils_unittest.py (132839 => 132840)


--- trunk/Tools/Scripts/webkitpy/common/system/logutils_unittest.py	2012-10-29 19:37:19 UTC (rev 132839)
+++ trunk/Tools/Scripts/webkitpy/common/system/logutils_unittest.py	2012-10-29 19:54:17 UTC (rev 132840)
@@ -107,8 +107,12 @@
 
     def test_info_message(self):
         self._log.info("test message")
-        self._assert_log_messages(["unittest: [INFO] test message\n"])
+        self._assert_log_messages(["test message\n"])
 
+    def test_debug_message(self):
+        self._log.debug("test message")
+        self._assert_log_messages([])
+
     def test_below_threshold_message(self):
         # We test the boundary case of a logging level equal to 19.
         # In practice, we will probably only be calling log.debug(),
@@ -120,10 +124,22 @@
     def test_two_messages(self):
         self._log.info("message1")
         self._log.info("message2")
-        self._assert_log_messages(["unittest: [INFO] message1\n",
-                                   "unittest: [INFO] message2\n"])
+        self._assert_log_messages(["message1\n",
+                                   "message2\n"])
 
 
+class ConfigureLoggingVerboseTest(ConfigureLoggingTestBase):
+    def _logging_level(self):
+        return logging.DEBUG
+
+    def test_info_message(self):
+        self._log.info("test message")
+        self._assert_log_messages(["unittest: [INFO] test message\n"])
+
+    def test_debug_message(self):
+        self._log.debug("test message")
+        self._assert_log_messages(["unittest: [DEBUG] test message\n"])
+
 class ConfigureLoggingCustomLevelTest(ConfigureLoggingTestBase):
 
     """Tests configure_logging() with a custom logging level."""
@@ -135,7 +151,7 @@
 
     def test_logged_message(self):
         self._log.log(self._level, "test message")
-        self._assert_log_messages(["unittest: [Level 36] test message\n"])
+        self._assert_log_messages(["test message\n"])
 
     def test_below_threshold_message(self):
         self._log.log(self._level - 1, "test message")
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to