Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Slightly saner logging for unittests
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
richvdh committed Jul 25, 2016
1 parent 68a92af commit f16f0e1
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tests/unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,18 @@

import logging


# logging doesn't have a "don't log anything at all EVARRRR setting,
# but since the highest value is 50, 1000000 should do ;)
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("synapse.storage.SQL").setLevel(NEVER)
logging.getLogger("synapse.storage.txn").setLevel(NEVER)


def around(target):
Expand Down Expand Up @@ -70,8 +75,6 @@ def tearDown(orig):
return ret

logging.getLogger().setLevel(level)
# Don't set SQL logging
logging.getLogger("synapse.storage").setLevel(old_level)
return orig()

def assertObjectHasAttributes(self, attrs, obj):
Expand Down

0 comments on commit f16f0e1

Please sign in to comment.