Console logging can now be paused. Fixes #1353.

pull/1357/head
jMyles 2019-09-23 22:15:51 -07:00
parent c11e4a247c
commit 95ddada6c7
1 changed files with 11 additions and 1 deletions

View File

@ -14,7 +14,7 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with nucypher. If not, see <https://www.gnu.org/licenses/>.
"""
from contextlib import contextmanager
from functools import lru_cache
import pathlib
@ -79,6 +79,16 @@ class GlobalLoggerSettings:
def stop_console_logging(cls):
globalLogPublisher.removeObserver(console_observer)
@classmethod
@contextmanager
def pause_console_logging_while(cls):
was_already_going = console_observer in globalLogPublisher._observers
if was_already_going:
globalLogPublisher.removeObserver(console_observer)
yield
if was_already_going:
globalLogPublisher.addObserver(console_observer)
@classmethod
def start_text_file_logging(cls):
globalLogPublisher.addObserver(get_text_file_observer())