Changed default loglevel to ERROR when operating in notebooks
@@ -6,6 +6,19 @@ from loguru import logger
from tqdm import tqdm
+def _is_ipython_notebook():
+ try:
+ shell = get_ipython().__class__.__name__
+ if shell == 'ZMQInteractiveShell':
+ return True # Jupyter notebook or qtconsole
+ elif shell == 'TerminalInteractiveShell':
+ return False # Terminal running IPython
+ else:
+ return False # Other type (?)
+ except NameError:
+ return False # Probably standard Python interpreter
+
+
def config_logger(fmt, loglevel): # pragma: no cover
r"""
Configures loguru logger with the given format and log level.
@@ -73,7 +86,7 @@ class Settings: # pragma: no cover
'<level>{level: <8}</level> | ' \
'<cyan>{name}</cyan>:<cyan>{function}</cyan>:<cyan>{line}</cyan>' \
'\n--> <level>{message}</level>'
- _loglevel = "INFO"
+ _loglevel = "ERROR" if _is_ipython_notebook() else "INFO"
config_logger(_logger_fmt, _loglevel)
@property
