MCPcopy
hub / github.com/mne-tools/mne-python / set_log_level

Function set_log_level

mne/utils/_logging.py:188–221  ·  view source on GitHub ↗

Set the logging level. Parameters ---------- verbose : bool, str, int, or None The verbosity of messages to print. If a str, it can be either DEBUG, INFO, WARNING, ERROR, or CRITICAL. Note that these are for convenience and are equivalent to passing in logging.DE

(verbose=None, return_old_level=False, add_frames=None)

Source from the content-addressed store, hash-verified

186
187@fill_doc
188def set_log_level(verbose=None, return_old_level=False, add_frames=None):
189 """Set the logging level.
190
191 Parameters
192 ----------
193 verbose : bool, str, int, or None
194 The verbosity of messages to print. If a str, it can be either DEBUG,
195 INFO, WARNING, ERROR, or CRITICAL. Note that these are for
196 convenience and are equivalent to passing in logging.DEBUG, etc.
197 For bool, True is the same as 'INFO', False is the same as 'WARNING'.
198 If None, the environment variable MNE_LOGGING_LEVEL is read, and if
199 it doesn't exist, defaults to INFO.
200 return_old_level : bool
201 If True, return the old verbosity level.
202 %(add_frames)s
203
204 Returns
205 -------
206 old_level : int
207 The old level. Only returned if ``return_old_level`` is True.
208 """
209 old_verbose = logger.level
210 verbose = _parse_verbose(verbose)
211
212 if verbose != old_verbose:
213 logger.setLevel(verbose)
214 if add_frames is not None:
215 _filter.add_frames = int(add_frames)
216 fmt = "%(frame_info)s " if add_frames else ""
217 fmt += "%(message)s"
218 fmt = logging.Formatter(fmt)
219 for handler in logger.handlers:
220 handler.setFormatter(fmt)
221 return old_verbose if return_old_level else None
222
223
224def _parse_verbose(verbose):

Callers 4

test_logging_optionsFunction · 0.90
__init__.pyFile · 0.85
__enter__Method · 0.85
__exit__Method · 0.85

Calls 1

_parse_verboseFunction · 0.85

Tested by 1

test_logging_optionsFunction · 0.72