code: def monitor(self, msg, transformer=lambda _: _, unpack=False):
          
          def decorator(fn):
              @wraps(fn)
              def wrapper(*args, **kw):
                  results = fn(*args, **kw)
                  transformed = transformer(results)
                  if unpack:
                      if isinstance(results, dict):
                          self.notify(msg.format(**transformed))
                      else:
                          self.notify(msg.format(*transformed))
                  else:
                      self.notify(msg.format(transformed))
                  return results
              return wrapper
          return decorator
docs: Decorator that sends a notification to all listeners when the
          wrapped function returns, optionally reporting said function's return
          value(s).
  
          msg : str
              Message to send to all listeners.  If the message is a
              Python-formatted string, the wrapped function's return value will
              be inserted into the first positional placeholder (i.e. `{0}`).
  
          transformer : function
              Function to format the wrapped function's return value for
              insertion into the `msg` parameter.  NOTE: this does *not* modify
              the function's ultimate return value.  Instead, it changes what is
              inserted into the message.
              [Default: lambda _: _]
  
          unpack : bool
              If true, multiple return values will be unpacked and each element
              will be inserted in the corresponding placeholder of `msg`.  For
              ordered collections, insertion is done via positional placeholders.
              If the return-value is a `dict`, insertion is performed via keyword
              placeholders.
              [Default: False]