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 msg with args at the indicated logging level. It supports logging levels defined in Python’s logging module plus VERBOSE, either obtained directly from the logging module like logging.INFO, or from parameterized like param.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.INFO or param.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 WARNING and warnings are treated as exceptions (warnings_as_exceptions is True).

Examples

Log a message at the INFO level:

>>> 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.