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)[source]

Bases: json.encoder.JSONEncoder


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):
        iterable = iter(o)
    except TypeError:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return JSONEncoder.default(self, o)
vispy.util.logs.log_exception(level='warning', tb_skip=2)[source]

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.


See set_log_level for options.


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)[source]

Convenience function for setting the logging level

verbosebool, 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’.

matchstr | None

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


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

See also



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)[source]

Bases: object

Context manager that temporarily sets logging level


See set_log_level for options.

matchstr | None

The string to match.


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


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.


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