mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Allow easily silencing the server log during tests
This commit is contained in:
parent
7bc5e491b3
commit
d2535aa9cf
@ -86,6 +86,7 @@ class TestServer(Thread):
|
||||
log=ServerLog(level=ServerLog.WARN),
|
||||
)
|
||||
self.log = self.loop.log
|
||||
self.silence_log = self.log
|
||||
specialize(self)
|
||||
|
||||
def setup_defaults(self, kwargs):
|
||||
|
@ -159,6 +159,13 @@ class Log(object):
|
||||
def __call__(self, *args, **kwargs):
|
||||
self.prints(INFO, *args, **kwargs)
|
||||
|
||||
def __enter__(self):
|
||||
self.orig_filter_level = self.filter_level
|
||||
self.filter_level = self.ERROR + 100
|
||||
|
||||
def __exit__(self, *args):
|
||||
self.filter_level = self.orig_filter_level
|
||||
|
||||
class DevNull(Log):
|
||||
|
||||
def __init__(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user