pyrevit.coreutils.logger

Core logging module for pyRevit.

class pyrevit.coreutils.logger.DispatchingFormatter(log_formatters, log_default_formatter)

Bases: object

Dispatching formatter to format by log level.

Parameters:
  • (dict[int (log_formatters) – logging.Formatter]): dict of level:formatter key pairs
  • log_default_formatter (logging.Formatter) – default formatter
format(record)

Format given record by log level.

class pyrevit.coreutils.logger.LoggerWrapper(*args)

Bases: logging.Logger

Custom logging object.

Parameters:
  • val (type) – desc
  • val – desc
callHandlers(record)

Override logging.Logger.callHandlers

get_level()

Return current logging level.

has_errors()

Check if logger has reported any errors.

isEnabledFor(level)

Override logging.Logger.isEnabledFor

is_enabled_for(level)

Check if logger is enabled for level in pyRevit environment.

reset_level()

Reset logging level back to default.

set_debug_mode()

Activate debug mode. Log levels >= DEBUG are enabled.

set_level(level)

Set logging level to level.

set_quiet_mode()

Activate quiet mode. All log levels are disabled.

set_verbose_mode()

Activate verbose mode. Log levels >= INFO are enabled.

pyrevit.coreutils.logger.get_file_hndlr()

Return file logging handler object.

Returns:configured instance of python’s native stream handler
Return type:logging.FileHandler
pyrevit.coreutils.logger.get_logger(logger_name)

Register and return a logger with given name.

Caches all registered loggers and returns the same logger object on second call with the same logger name.

Parameters:
  • logger_name (str) – logger name
  • val (type) – desc
Returns:

logger object wrapper python’s native logger

Return type:

LoggerWrapper

Example

>>> get_logger('my command')
... <LoggerWrapper ...>
pyrevit.coreutils.logger.get_stdout_hndlr()

Return stdout logging handler object.

Returns:configured instance of python’s native stream handler
Return type:logging.StreamHandler
pyrevit.coreutils.logger.loggers_have_errors()

Check if any errors have been reported by any of registered loggers.

pyrevit.coreutils.logger.set_file_logging(status)

Set file logging status (enable/disable).

Parameters:status (bool) – True to enable, False to disable