finesse.utilities.misc.logs¶
- finesse.utilities.misc.logs(level=None, exclude=None, fmt=None, datefmt=None, jupyter_tracebacks=None)[source]¶
Change the default Finesse log stream handler behaviour in the encapsulated context.
- Parameters
level : str or int, optional
The minimum log levels to print. The standard log levels “debug”, “info”, “warning”, “error” and “critical” are supported, as are their corresponding level numbers (see
logging
).exclude : str or list of str, optional
Log channel(s) to exclude. Simple wildcards are supported:
*
matches 0 or more characters?
matches any single character[abc]
matches any characters in abc[!abc]
matches any characters not in abc
fmt, datefmt : str, optional
The stream format to use. The string specified for fmt should use “{” style parameters as supported by
logging.Formatter
. The datefmt string should be atime.strftime()
compatible format. Defaults to the existing builtin stream handler’s default format.jupyter_tracebacks : bool, optional
Whether to show full Jupyter tracebacks for
parsing errors
raised within the encapsulated context. Defaults to None, which leaves the current value (which is by default determined by the environment in which Finesse is running) unchanged.- Raises
-
If the current
finesse
root logger’s first handler was not the one autoconfigured by Finesse upon first import. This function does not handle cases where the user has configured their own logging.
Examples
Print debug logs during parsing.
>>> from finesse import Model >>> from finesse.utilities import logs >>> model = Model() >>> with logs(level="debug"): >>> model.parse("laser l1 P=1")