Logging
The way commands are added to a dispatcher is through the add_command()
method.
Implementation example of add_command()
def add_command(self, handler, func, **options):
"Add a command to a dispatcher"
@self.agent.on(handler, **options)
def handler_fn(*args, **kwargs):
response = func(*args, **kwargs)
if response:
message = {"handler": kwargs["body"], "response": response}
self.log.send(msg=message)
The result of the command, if any, will be logged automatically to the logging channel specified in the Dispatcher.