Commit 0dd62360 authored by dpranke@chromium.org's avatar dpranke@chromium.org

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):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@132840 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 2dfcde15
2012-10-29 Dirk Pranke <dpranke@chromium.org>
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 <christophe.dumez@intel.com>
[CMAKE] Add TestNetscapePlugIn/Tests/NPRuntimeCallsWithNullNPP.cpp to CMakeLists.txt
......
......@@ -125,7 +125,7 @@ def get_logger(path):
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 @@ def _default_handlers(stream):
# 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 @@ def configure_logging(logging_level=None, logger=None, stream=None,
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)
......
......@@ -107,7 +107,11 @@ class ConfigureLoggingTest(ConfigureLoggingTestBase):
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.
......@@ -120,9 +124,21 @@ class ConfigureLoggingTest(ConfigureLoggingTestBase):
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):
......@@ -135,7 +151,7 @@ class ConfigureLoggingCustomLevelTest(ConfigureLoggingTestBase):
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")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment