Skip to main content
`Ctrl`+`K`

# vispy.util.logs module

class vispy.util.logs.NumPyJSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)

  Bases: `JSONEncoder`

  default(obj)

    Implement this method in a subclass such that it returns a serializable object for `o`, or calls the base implementation (to raise a `TypeError`).

    For example, to support arbitrary iterators, you could implement default like this:

        def default(self, o):
            try:
                iterable = iter(o)
            except TypeError:
                pass
            else:
                return list(iterable)
            # Let the base class default method raise the TypeError
            return super().default(o)

vispy.util.logs.log_exception(level='warning', tb_skip=2)

  Send an exception and traceback to the logger.

  This function is used in cases where an exception is handled safely but nevertheless should generate a descriptive error message. An extra line is inserted into the stack trace indicating where the exception was caught.

  Parameters:
    level str

      See `set_log_level` for options.

    tb_skip int

      The number of traceback entries to ignore, prior to the point where the exception was caught. The default is 2.

vispy.util.logs.set_log_level(verbose, match=None, return_old=False)

  Convenience function for setting 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.DEBUG, etc. For bool, True is the same as ‘INFO’, False is the same as ‘WARNING’.

    match str | None

      String to match. Only those messages that both contain a substring that regexp matches `'match'` (and the `verbose` level) will be displayed.

    return_old bool

      If True, return the old verbosity level and old match.

  See also

  `vispy.util.use_log_level`

  Notes

  If `verbose=='debug'`, then the `vispy` method emitting the log message will be prepended to each log message, which is useful for debugging. If `verbose=='debug'` or `match is not None`, then a small performance overhead is added. Thus it is suggested to only use these options when performance is not crucial.

class vispy.util.logs.use_log_level(level, match=None, record=False, print_msg=True)

  Bases: `object`

  Context manager that temporarily sets logging level

  Parameters:
    level str

      See `set_log_level` for options.

    match str | None

      The string to match.

    record bool

      If True, the context manager will keep a record of the logging messages generated by vispy. Otherwise, an empty list will be returned.

    print_msg bool

      If False, printing of (all) messages will be suppressed. This is mainly useful in testing. False only works in record=True mode, if not recording messages, consider setting level appropriately.

  Returns:
    records list

      As a context manager, an empty list or the list of logging messages will be returned (depending on the input `record`).