code: def auditlog(*, event, actor, data, level=logging.INFO):
      
      try:
          entry = AuditLog()
          entry.event = event
          entry.actor = actor
          entry.data = data
  
          db.session.add(entry)
          db.session.commit()
  
          _AUDIT_LOGGER.log(
              logging.getLevelName(level) if type(level) == str else level,
              {
                  'event': event,
                  'actor': actor,
                  'data': data,
              }
          )
  
      except Exception:
          logging.getLogger(__name__).exception('Failed adding audit log event')
          db.session.rollback()
docs: Generate and insert a new event
  
      Args:
          event (`str`): Action performed
          actor (`str`): Actor (user or subsystem) triggering the event
          data (`dict`): Any extra data necessary for describing the event
          level (`str` or `int`): Log level for the message. Uses standard python logging level names / numbers
  
      Returns:
          `None`