Skip to content
Snippets Groups Projects
Commit f16f0e16 authored by Richard van der Hoff's avatar Richard van der Hoff
Browse files

Slightly saner logging for unittests

1. Give the handler used for logging in unit tests a formatter, so that the
output is slightly more meaningful

2. Log some synapse.storage stuff, because it's useful.
parent 68a92afc
Branches
Tags
No related merge requests found
...@@ -17,13 +17,18 @@ from twisted.trial import unittest ...@@ -17,13 +17,18 @@ from twisted.trial import unittest
import logging import logging
# logging doesn't have a "don't log anything at all EVARRRR setting, # logging doesn't have a "don't log anything at all EVARRRR setting,
# but since the highest value is 50, 1000000 should do ;) # but since the highest value is 50, 1000000 should do ;)
NEVER = 1000000 NEVER = 1000000
logging.getLogger().addHandler(logging.StreamHandler()) handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter(
"%(levelname)s:%(name)s:%(message)s [%(pathname)s:%(lineno)d]"
))
logging.getLogger().addHandler(handler)
logging.getLogger().setLevel(NEVER) logging.getLogger().setLevel(NEVER)
logging.getLogger("synapse.storage.SQL").setLevel(NEVER)
logging.getLogger("synapse.storage.txn").setLevel(NEVER)
def around(target): def around(target):
...@@ -70,8 +75,6 @@ class TestCase(unittest.TestCase): ...@@ -70,8 +75,6 @@ class TestCase(unittest.TestCase):
return ret return ret
logging.getLogger().setLevel(level) logging.getLogger().setLevel(level)
# Don't set SQL logging
logging.getLogger("synapse.storage").setLevel(old_level)
return orig() return orig()
def assertObjectHasAttributes(self, attrs, obj): def assertObjectHasAttributes(self, attrs, obj):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment