vsgen.util.logger module

This module provides all functionality for the tracking events during an VSG process.

The module defines the class VSGLogger. The VSGLogger class provides the main functionality of using Python’s native logging process. Since Python allows period-separated hierarchical value (e.g. “VSG.Module.ModuleFeature”) and loggers that are further down in the hierarchical list are children of loggers higher up in the list, the VSG Logger manages the hierarchy of loggers in the VSG namespace (i.e. VSG.*).

For completeness, all logging activing in VSG package must go through the VSG Logger.

class vsgen.util.logger.VSGLogger(filepath=None, threshold=20)[source]

Bases: object

The VSG Logger manages messages associate with various priority level.

Optional, it can redirect the messages to any output channel (usually a file).

BASENAME = 'VSG'
class LevelFilter(levels=None)[source]

Bases: logging.Filter

The LevelFilter class implements a Filter Object specific to the VSGLogger

filter(record)[source]

Returns NoneZero if the recorsd should be logger; zero otherwise.

close()[source]

Closes and unregisters all logging handlers.

classmethod critical(name, message, *args)[source]

Convenience function to log a message at the CRITICAL level.

Parameters:
  • name – The name of the logger instance in the VSG namespace (VSG.<name>)
  • message – A message format string.
  • args – The arguments that are are merged into msg using the string formatting operator.
..note:

The native logger’s kwargs are not used in this function.

classmethod debug(name, message, *args)[source]

Convenience function to log a message at the DEBUG level.

Parameters:
  • name – The name of the logger instance in the VSG namespace (VSG.<name>)
  • message – A message format string.
  • args – The arguments that are are merged into msg using the string formatting operator.
..note:

The native logger’s kwargs are not used in this function.

classmethod error(name, message, *args)[source]

Convenience function to log a message at the ERROR level.

Parameters:
  • name – The name of the logger instance in the VSG namespace (VSG.<name>)
  • message – A message format string.
  • args – The arguments that are are merged into msg using the string formatting operator.
..note:

The native logger’s kwargs are not used in this function.

classmethod exception(name, message, *args)[source]

Convenience function to log a message at the ERROR level with additonal exception information.

Parameters:
  • name – The name of the logger instance in the VSG namespace (VSG.<name>)
  • message – A message format string.
  • args – The arguments that are are merged into msg using the string formatting operator.
..note:

This method should only be called from an exception handler.

classmethod getLogger(name=None)[source]

Retrieves the Python native logger

Parameters:name – The name of the logger instance in the VSG namespace (VSG.<name>); a None value will use the VSG root.
Returns:The instacne of the Python logger object.
classmethod info(name, message, *args)[source]

Convenience function to log a message at the INFO level.

Parameters:
  • name – The name of the logger instance in the VSG namespace (VSG.<name>)
  • message – A message format string.
  • args – The arguments that are are merged into msg using the string formatting operator.
..note:

The native logger’s kwargs are not used in this function.

classmethod warning(name, message, *args)[source]

Convenience function to log a message at the WARNING level.

Parameters:
  • name – The name of the logger instance in the VSG namespace (VSG.<name>)
  • message – A message format string.
  • args – The arguments that are are merged into msg using the string formatting operator.
..note:

The native logger’s kwargs are not used in this function.