def __init__(self, status, message, **kwargs): """A record in the log""" kwargs['status'] = status kwargs['message'] = message # we need to hash down the payload if there is one if 'payload' in kwargs and kwargs['payload'] is not None: kwargs['payload'] = json.dumps(dict(kwargs.get('payload'))) AppLogMgr.store(**kwargs)
def admin_applog(request): """Return applog data for admin use.""" rdict = request.GET # Support optional filter parameters days = int(rdict.get('days', 1)) status = rdict.get('status', None) message = rdict.get('message', None) log_list = AppLogMgr.find( days=days, message_filter=message, status=status, ) ret = { 'count': len(log_list), 'logs': [dict(l) for l in log_list], } return _api_response(request, ret)