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

Commit

Permalink
Merge pull request #947 from matrix-org/rav/unittest_logging
Browse files Browse the repository at this point in the history
Slightly saner logging for unittests
  • Loading branch information
richvdh authored Jul 25, 2016
2 parents 68a92af + f16f0e1 commit e73ad8d
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 e73ad8d

Please sign in to comment.