param.parameterized.Parameters.log#
- Parameters.log(level: int, msg: str, *args, **kw) None[source]#
Log a message at the specified logging level.
This method logs a message constructed by merging
msgwithargsat the indicated logging level. It supports logging levels defined in Python’sloggingmodule plus VERBOSE, either obtained directly from the logging module likelogging.INFO, or from parameterized likeparam.parameterized.INFO.Supported logging levels include (in order of severity): DEBUG, VERBOSE, INFO, WARNING, ERROR, CRITICAL
- Parameters:
level (int) – The logging level at which the message should be logged e.g.,
logging.INFOorparam.INFO.msg (str) – The message to log. This message can include format specifiers, which will be replaced with values from
args.*args (tuple) – Arguments to merge into msg using the format specifiers.
**kw (dict) – Additional keyword arguments passed to the logging implementation.
- Raises:
Exception – If the logging level is
WARNINGand warnings are treated as exceptions (warnings_as_exceptionsis True).
Examples
Log a message at the
INFOlevel:>>> import param >>> class MyClass(param.Parameterized): ... def log_message(self): ... self.param.log(INFO, "This is an info message.")
>>> instance = MyClass() >>> instance.param.log(param.INFO, "This is an info message.") INFO:param.MyClass...: This is an info message.
Log a warning and treat it as an exception:
>>> param.parameterized.warnings_as_exceptions = True >>> instance.param.log(param.WARNING, "This will raise an exception.") ... Exception: Warning: This will raise an exception.