Logger Helper

Logger Helper main classes and utility functions.

class logger_helper.LoggerHelper(logger, log_level)

Log calls to class methods and functions.

Create a new helper that writes to a specific logger.

  • logger (logging.Logger) – The logger to write to.
  • log_level (int) – The log level to log at. This should be one of the logging.XXXXX constants, for example logging.DEBUG.

str – The format string to use when formatting a call to a callable. The available tokens are:

  • callable - The name of the callable.
  • args - The arguments passed to the callable. The format of the arguments is defined in the argument_format property.

str – The format of each argument. The available tokens are:

  • name - The name of the argument.
  • value - The value of the argument.

str – The separator to join the arguments together with.


str – The format to log the return with. The available tokens are:

  • callable - The name of the callable.
  • return_value - The return value (after it’s been run through repr).

str – The format to log exceptions with. The available tokens are:

  • callable - The name of the callable.
  • name - The name of the exception.
  • message - The exception message.

Wrap the class methods or functions in our decorator.

Raises:TypeError – When the object isn’t a class or function.
Returns:The fully wrapped class or function.

Wrap a classes methods (that don’t start and end with __).

Parameters:cls – The class to wrap.
Returns:A copy of the given class with all of it’s methods wrapped.
Return type:cls

Wrap a function.

Parameters:function – The function to wrap.
Returns:A wrapped copy of the given function.
Return type:function

Wrap a method belonging to a class.

Returns:A wrapped copy of the fiven method.
Return type:method
mod(mod, symbols=None)

Wrap an entire module’s classes and functions.

  • mod (module) – The module to wrap.
  • symbols (list) – If this is specified, only the symbols (classes/functions) listed will be wrapped. Each item in the list should be a string.

Nothing is returned, the class is wrapped in place.

Return type:



Get the fully qualified name of a callable.

Parameters:clbl – The callable to get the name for.
Returns:A string representing the full path to the given callable.
Return type:str